MCPcopy
hub / github.com/vercel/next.js / createRedboxSnapshot

Function createRedboxSnapshot

test/lib/add-redbox-matchers.ts:284–313  ·  view source on GitHub ↗
(
  browser: Playwright,
  next: NextInstance | null,
  opts?: ErrorSnapshotOptions
)

Source from the content-addressed store, hash-verified

282export type RedboxSnapshot = ErrorSnapshot | ErrorSnapshot[]
283
284export 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
315expect.extend({
316 async toDisplayRedbox(

Callers 3

toDisplayRedboxFunction · 0.85
toDisplayCollapsedRedboxFunction · 0.85

Calls 5

getRedboxTotalErrorCountFunction · 0.90
createErrorSnapshotFunction · 0.85
clickMethod · 0.80
waitForElementByCssMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected