MCPcopy Index your code
hub / github.com/rrweb-io/rrweb / assertSnapshot

Function assertSnapshot

packages/all/test/utils.ts:246–266  ·  view source on GitHub ↗
(
  snapshotsOrPage: eventWithTime[] | puppeteer.Page,
)

Source from the content-addressed store, hash-verified

244}
245
246export async function assertSnapshot(
247 snapshotsOrPage: eventWithTime[] | puppeteer.Page,
248) {
249 let snapshots: eventWithTime[];
250 if (!Array.isArray(snapshotsOrPage)) {
251 // make sure page has finished executing js
252 await waitForRAF(snapshotsOrPage);
253 await snapshotsOrPage.waitForFunction(
254 'window.snapshots && window.snapshots.length > 0',
255 );
256
257 snapshots = (await snapshotsOrPage.evaluate(
258 'window.snapshots',
259 )) as eventWithTime[];
260 } else {
261 snapshots = snapshotsOrPage;
262 }
263
264 expect(snapshots).toBeDefined();
265 expect(stringifySnapshots(snapshots)).toMatchSnapshot();
266}
267
268export async function waitForRAF(
269 pageOrFrame: puppeteer.Page | puppeteer.Frame,

Calls 3

evaluateMethod · 0.80
waitForRAFFunction · 0.70
stringifySnapshotsFunction · 0.70

Tested by

no test coverage detected