Option to mask inputs (#80)

* Option to mask inputs

Added option 'maskAllInputs' to replace all user inputs with an Asterisk.

* Update types.d.ts
This commit is contained in:
Sebastian Jakob
2026-04-01 12:00:00 +08:00
committed by yz-yu
parent 2a1bfc9316
commit 2502913883
6 changed files with 718 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ interface ISuite extends Suite {
}
describe('record integration tests', function(this: ISuite) {
const getHtml = (fileName: string): string => {
const getHtml = (fileName: string, maskAllInputs: boolean = false): string => {
const filePath = path.resolve(__dirname, `./html/${fileName}`);
const html = fs.readFileSync(filePath, 'utf8');
return html.replace(
@@ -24,7 +24,8 @@ describe('record integration tests', function(this: ISuite) {
emit: event => {
console.log(event);
window.snapshots.push(event);
}
},
maskAllInputs: ${maskAllInputs}
});
</script>
</body>
@@ -148,6 +149,21 @@ describe('record integration tests', function(this: ISuite) {
assertSnapshot(snapshots, __filename, 'ignore');
});
it('should not record input values if maskAllInputs is enabled', async () => {
const page: puppeteer.Page = await this.browser.newPage();
await page.goto('about:blank');
await page.setContent(getHtml.call(this, 'form.html', true));
await page.type('input[type="text"]', 'test');
await page.click('input[type="radio"]');
await page.click('input[type="checkbox"]');
await page.type('textarea', 'textarea test');
await page.select('select', '1');
const snapshots = await page.evaluate('window.snapshots');
assertSnapshot(snapshots, __filename, 'mask');
});
it('should not record blocked elements and its child nodes', async () => {
const page: puppeteer.Page = await this.browser.newPage();
await page.goto('about:blank');