( browser: Playwright, next: NextInstance | null, opts?: ErrorSnapshotOptions )
| 282 | export type RedboxSnapshot = ErrorSnapshot | ErrorSnapshot[] |
| 283 | |
| 284 | export async function createRedboxSnapshot( |
| 285 | browser: Playwright, |
| 286 | next: NextInstance | null, |
| 287 | opts?: ErrorSnapshotOptions |
| 288 | ): Promise<RedboxSnapshot> { |
| 289 | const errorTally = await getRedboxTotalErrorCount(browser) |
| 290 | const errorSnapshots: ErrorSnapshot[] = [] |
| 291 | |
| 292 | for (let errorIndex = 0; errorIndex < errorTally; errorIndex++) { |
| 293 | const errorSnapshot = await createErrorSnapshot(browser, next, opts) |
| 294 | errorSnapshots.push(errorSnapshot) |
| 295 | |
| 296 | if (errorIndex < errorTally - 1) { |
| 297 | // Go to next error |
| 298 | await browser |
| 299 | .waitForElementByCss('[data-nextjs-dialog-error-next]') |
| 300 | .click() |
| 301 | // TODO: Wait for suspended content if the click triggered it. |
| 302 | await browser.waitForElementByCss( |
| 303 | `[data-nextjs-dialog-error-index="${errorIndex + 1}"]` |
| 304 | ) |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | return errorSnapshots.length === 1 |
| 309 | ? // Most of the Redbox tests will just show a single error. |
| 310 | // We optimize display for that case. |
| 311 | errorSnapshots[0] |
| 312 | : errorSnapshots |
| 313 | } |
| 314 | |
| 315 | expect.extend({ |
| 316 | async toDisplayRedbox( |
no test coverage detected