( snapshotsOrPage: eventWithTime[] | puppeteer.Page, )
| 244 | } |
| 245 | |
| 246 | export 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 | |
| 268 | export async function waitForRAF( |
| 269 | pageOrFrame: puppeteer.Page | puppeteer.Frame, |
no test coverage detected