From 0074c102d6d3ef7497a42fd3ab2ffc7470fdc6aa Mon Sep 17 00:00:00 2001 From: Yun Feng Date: Mon, 9 Jan 2023 18:13:15 +0800 Subject: [PATCH] Update packages/rrweb/test/record.test.ts Co-authored-by: Justin Halsall --- packages/rrweb/test/record.test.ts | 37 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/rrweb/test/record.test.ts b/packages/rrweb/test/record.test.ts index a146dc0c4f..2bbe5af55e 100644 --- a/packages/rrweb/test/record.test.ts +++ b/packages/rrweb/test/record.test.ts @@ -591,27 +591,30 @@ describe('record', function (this: ISuite) { it('captures adopted stylesheets of shadow doms in checkout full snapshot', async () => { await ctx.page.evaluate(() => { - document.body.innerHTML = ` -
entry
- `; + return new Promise((resolve) => { + document.body.innerHTML = ` +
entry
+ `; - let shadowHost = document.querySelector('div')!; - shadowHost!.attachShadow({ mode: 'open' }); - const sheet = new CSSStyleSheet(); - sheet.replaceSync!('h1 {color: blue;}'); - shadowHost.shadowRoot!.adoptedStyleSheets = [sheet]; + let shadowHost = document.querySelector('div')!; + shadowHost!.attachShadow({ mode: 'open' }); + const sheet = new CSSStyleSheet(); + sheet.replaceSync!('h1 {color: blue;}'); + shadowHost.shadowRoot!.adoptedStyleSheets = [sheet]; - const { rrweb, emit } = (window as unknown) as IWindow; - rrweb.record({ - emit, - }); + const { rrweb, emit } = (window as unknown) as IWindow; + rrweb.record({ + emit, + }); - setTimeout(() => { - // When a full snapshot is checked out manually, all adoptedStylesheets should also be captured. - rrweb.record.takeFullSnapshot(true); - }, 10); + setTimeout(() => { + // When a full snapshot is checked out manually, all adoptedStylesheets should also be captured. + rrweb.record.takeFullSnapshot(true); + resolve(undefined); + }, 10); + }); }); - await ctx.page.waitForTimeout(200); + await waitForRAF(page); assertSnapshot(ctx.events); });