MCPcopy
hub / github.com/rrweb-io/rrweb / assertSnapshot

Function assertSnapshot

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

Source from the content-addressed store, hash-verified

300}
301
302export async function assertSnapshot(
303 snapshotsOrPage: eventWithTime[] | puppeteer.Page,
304) {
305 let snapshots: eventWithTime[];
306 if (!Array.isArray(snapshotsOrPage)) {
307 // make sure page has finished executing js
308 await waitForRAF(snapshotsOrPage);
309 await snapshotsOrPage.waitForFunction(
310 'window.snapshots && window.snapshots.length > 0',
311 );
312
313 snapshots = (await snapshotsOrPage.evaluate(
314 'window.snapshots',
315 )) as eventWithTime[];
316 } else {
317 snapshots = snapshotsOrPage;
318 }
319
320 expect(snapshots).toBeDefined();
321 expect(stringifySnapshots(snapshots)).toMatchSnapshot();
322}
323
324export function replaceLast(str: string, find: string, replace: string) {
325 const index = str.lastIndexOf(find);

Callers 6

record.test.tsFile · 0.90
dialog.test.tsFile · 0.90
webgl.test.tsFile · 0.90

Calls 3

evaluateMethod · 0.80
waitForRAFFunction · 0.70
stringifySnapshotsFunction · 0.70

Tested by 1