nested record iframe (#63)
* pick nested branch * iframe snapshot * temp: add bundle file to git * revert ignore file * refactor iframe impl 1. do callback one iframe is loaded, let rrweb handle the rest 2. handle iframe as normal element in rebuild * rename hook function
This commit is contained in:
@@ -119,3 +119,50 @@ describe('integration tests', function (this: ISuite) {
|
||||
}).timeout(5000);
|
||||
}
|
||||
});
|
||||
|
||||
describe('iframe integration tests', function (this: ISuite) {
|
||||
const iframeHtml = path.join(__dirname, 'iframe-html/main.html');
|
||||
const raw = fs.readFileSync(iframeHtml, 'utf-8');
|
||||
|
||||
before(async () => {
|
||||
this.server = await server();
|
||||
this.browser = await puppeteer.launch({
|
||||
// headless: false,
|
||||
});
|
||||
|
||||
const bundle = await rollup.rollup({
|
||||
input: path.resolve(__dirname, '../src/index.ts'),
|
||||
plugins: [typescript()],
|
||||
});
|
||||
const { code } = await bundle.generate({
|
||||
name: 'rrweb',
|
||||
format: 'iife',
|
||||
});
|
||||
this.code = code;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await this.browser.close();
|
||||
await this.server.close();
|
||||
});
|
||||
|
||||
it('snapshot async iframes', async () => {
|
||||
const page: puppeteer.Page = await this.browser.newPage();
|
||||
// console for debug
|
||||
// tslint:disable-next-line: no-console
|
||||
page.on('console', (msg) => console.log(msg.text()));
|
||||
await page.goto(`http://localhost:3030/html`);
|
||||
await page.setContent(raw, {
|
||||
waitUntil: 'load',
|
||||
});
|
||||
const snapshotResult = JSON.stringify(
|
||||
await page.evaluate(`${this.code};
|
||||
rrweb.snapshot(document)[0];
|
||||
`),
|
||||
null,
|
||||
2,
|
||||
);
|
||||
const result = matchSnapshot(snapshotResult, __filename, this.title);
|
||||
assert(result.pass, result.pass ? '' : result.report());
|
||||
}).timeout(5000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user