Unverified Commit 8ea2830b authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

Rename `waitForAndOpenRuntimeError` to `openRedbox` (#72996)

parent 4875c584
...@@ -41,7 +41,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -41,7 +41,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
) )
await session.evaluate(() => document.querySelector('a').click()) await session.evaluate(() => document.querySelector('a').click())
await session.waitForAndOpenRuntimeError() await session.openRedbox()
expect(await session.getRedboxSource()).toMatchSnapshot() expect(await session.getRedboxSource()).toMatchSnapshot()
}) })
...@@ -149,7 +149,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -149,7 +149,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`export default function FunctionDefault() { throw new Error('no'); }` `export default function FunctionDefault() { throw new Error('no'); }`
) )
await session.waitForAndOpenRuntimeError() await session.openRedbox()
expect(await session.getRedboxSource()).toMatchSnapshot() expect(await session.getRedboxSource()).toMatchSnapshot()
expect( expect(
await session.evaluate(() => document.querySelector('h2').textContent) await session.evaluate(() => document.querySelector('h2').textContent)
...@@ -390,7 +390,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -390,7 +390,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
) )
await session.evaluate(() => document.querySelector('button').click()) await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError() await session.openRedbox()
const header = await session.getRedboxDescription() const header = await session.getRedboxDescription()
expect(header).toMatchSnapshot() expect(header).toMatchSnapshot()
...@@ -435,7 +435,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -435,7 +435,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
) )
await session.evaluate(() => document.querySelector('button').click()) await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError() await session.openRedbox()
const header2 = await session.getRedboxDescription() const header2 = await session.getRedboxDescription()
expect(header2).toMatchSnapshot() expect(header2).toMatchSnapshot()
...@@ -480,7 +480,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -480,7 +480,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
) )
await session.evaluate(() => document.querySelector('button').click()) await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError() await session.openRedbox()
const header3 = await session.getRedboxDescription() const header3 = await session.getRedboxDescription()
expect(header3).toMatchSnapshot() expect(header3).toMatchSnapshot()
...@@ -525,7 +525,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -525,7 +525,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
) )
await session.evaluate(() => document.querySelector('button').click()) await session.evaluate(() => document.querySelector('button').click())
await session.waitForAndOpenRuntimeError() await session.openRedbox()
const header4 = await session.getRedboxDescription() const header4 = await session.getRedboxDescription()
expect(header4).toEqual( expect(header4).toEqual(
......
...@@ -49,7 +49,7 @@ describe('Error overlay - error message urls', () => { ...@@ -49,7 +49,7 @@ describe('Error overlay - error message urls', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
const link = await browser.elementByCss('#nextjs__container_errors__link a') const link = await browser.elementByCss('#nextjs__container_errors__link a')
const text = await link.text() const text = await link.text()
......
...@@ -136,7 +136,7 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => { ...@@ -136,7 +136,7 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => {
await session.evaluate(() => document.querySelector('p').textContent) await session.evaluate(() => document.querySelector('p').textContent)
).toBe('1') ).toBe('1')
await session.waitForAndOpenRuntimeError() await session.openRedbox()
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"index.js (7:11) @ Index.useCallback[increment] "index.js (7:11) @ Index.useCallback[increment]
...@@ -282,7 +282,7 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => { ...@@ -282,7 +282,7 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => {
) )
await new Promise((resolve) => setTimeout(resolve, 1000)) await new Promise((resolve) => setTimeout(resolve, 1000))
await session.waitForAndOpenRuntimeError() await session.openRedbox()
expect(await session.getRedboxSource()).not.toInclude( expect(await session.getRedboxSource()).not.toInclude(
"Expected '}', got '<eof>'" "Expected '}', got '<eof>'"
) )
......
...@@ -71,9 +71,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -71,9 +71,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot( expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
...@@ -153,9 +152,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -153,9 +152,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
...@@ -203,9 +201,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -203,9 +201,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
...@@ -239,9 +236,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -239,9 +236,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
...@@ -288,9 +284,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -288,9 +284,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
...@@ -330,9 +325,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -330,9 +325,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot( expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
...@@ -378,9 +372,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -378,9 +372,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2) expect(await getRedboxTotalErrorCount(browser)).toBe(2)
// FIXME: Should also have "text nodes cannot be a child of tr" // FIXME: Should also have "text nodes cannot be a child of tr"
...@@ -427,9 +420,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -427,9 +420,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(` expect(await session.getRedboxDescription()).toMatchInlineSnapshot(`
...@@ -487,7 +479,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -487,7 +479,7 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session } = sandbox const { session } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
if (isTurbopack) { if (isTurbopack) {
...@@ -572,9 +564,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -572,9 +564,8 @@ describe('Error overlay for hydration errors in App router', () => {
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2) expect(await getRedboxTotalErrorCount(browser)).toBe(2)
const description = await session.getRedboxDescription() const description = await session.getRedboxDescription()
...@@ -631,9 +622,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -631,9 +622,8 @@ describe('Error overlay for hydration errors in App router', () => {
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2) expect(await getRedboxTotalErrorCount(browser)).toBe(2)
const description = await session.getRedboxDescription() const description = await session.getRedboxDescription()
...@@ -670,9 +660,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -670,9 +660,8 @@ describe('Error overlay for hydration errors in App router', () => {
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2) expect(await getRedboxTotalErrorCount(browser)).toBe(2)
const description = await session.getRedboxDescription() const description = await session.getRedboxDescription()
...@@ -724,9 +713,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -724,9 +713,8 @@ describe('Error overlay for hydration errors in App router', () => {
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(2) expect(await getRedboxTotalErrorCount(browser)).toBe(2)
const description = await session.getRedboxDescription() const description = await session.getRedboxDescription()
...@@ -796,9 +784,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -796,9 +784,7 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
retry(async () => { retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(4) expect(await getRedboxTotalErrorCount(browser)).toBe(4)
...@@ -868,9 +854,8 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -868,9 +854,8 @@ describe('Error overlay for hydration errors in App router', () => {
]) ])
) )
const { session, browser } = sandbox const { session, browser } = sandbox
await session.waitForAndOpenRuntimeError() await session.openRedbox()
await session.assertHasRedbox()
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
......
...@@ -45,7 +45,7 @@ describe('Error Overlay version staleness', () => { ...@@ -45,7 +45,7 @@ describe('Error Overlay version staleness', () => {
` `
) )
await session.waitForAndOpenRuntimeError() await session.openRedbox()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(await getStaleness(browser)).toMatchInlineSnapshot( expect(await getStaleness(browser)).toMatchInlineSnapshot(
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { import {
assertHasRedbox,
getRedboxCallStack, getRedboxCallStack,
getRedboxDescription, getRedboxDescription,
getRedboxTitle, getRedboxTitle,
getRedboxSource, getRedboxSource,
getRedboxTotalErrorCount, getRedboxTotalErrorCount,
waitForAndOpenRuntimeError, openRedbox,
} from 'next-test-utils' } from 'next-test-utils'
async function getRedboxResult(browser: any) { async function getRedboxResult(browser: any) {
...@@ -33,8 +32,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -33,8 +32,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const browser = await next.browser('/browser/event') const browser = await next.browser('/browser/event')
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -82,8 +80,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -82,8 +80,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture browser console error in render and dedupe if necessary', async () => { it('should capture browser console error in render and dedupe if necessary', async () => {
const browser = await next.browser('/browser/render') const browser = await next.browser('/browser/render')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -129,8 +126,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -129,8 +126,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture browser console error in render and dedupe when multi same errors logged', async () => { it('should capture browser console error in render and dedupe when multi same errors logged', async () => {
const browser = await next.browser('/browser/render') const browser = await next.browser('/browser/render')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -176,8 +172,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -176,8 +172,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture server replay string error from console error', async () => { it('should capture server replay string error from console error', async () => {
const browser = await next.browser('/ssr') const browser = await next.browser('/ssr')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -223,8 +218,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -223,8 +218,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should capture server replay error instance from console error', async () => { it('should capture server replay error instance from console error', async () => {
const browser = await next.browser('/ssr-error-instance') const browser = await next.browser('/ssr-error-instance')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -270,8 +264,7 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -270,8 +264,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
it('should be able to capture rsc logged error', async () => { it('should be able to capture rsc logged error', async () => {
const browser = await next.browser('/rsc') const browser = await next.browser('/rsc')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { import {
assertHasRedbox,
getRedboxCallStack, getRedboxCallStack,
getRedboxDescription, getRedboxDescription,
getRedboxTitle, getRedboxTitle,
getRedboxSource, getRedboxSource,
getRedboxTotalErrorCount, getRedboxTotalErrorCount,
waitForAndOpenRuntimeError, openRedbox,
} from 'next-test-utils' } from 'next-test-utils'
async function getRedboxResult(browser: any) { async function getRedboxResult(browser: any) {
...@@ -41,8 +40,7 @@ describe('app-dir - capture-console-error', () => { ...@@ -41,8 +40,7 @@ describe('app-dir - capture-console-error', () => {
const browser = await next.browser('/browser/event') const browser = await next.browser('/browser/event')
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -88,8 +86,7 @@ describe('app-dir - capture-console-error', () => { ...@@ -88,8 +86,7 @@ describe('app-dir - capture-console-error', () => {
it('should capture browser console error in render and dedupe if necessary', async () => { it('should capture browser console error in render and dedupe if necessary', async () => {
const browser = await next.browser('/browser/render') const browser = await next.browser('/browser/render')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -135,8 +132,7 @@ describe('app-dir - capture-console-error', () => { ...@@ -135,8 +132,7 @@ describe('app-dir - capture-console-error', () => {
it('should capture browser console error in render and dedupe when multi same errors logged', async () => { it('should capture browser console error in render and dedupe when multi same errors logged', async () => {
const browser = await next.browser('/browser/render') const browser = await next.browser('/browser/render')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -182,8 +178,7 @@ describe('app-dir - capture-console-error', () => { ...@@ -182,8 +178,7 @@ describe('app-dir - capture-console-error', () => {
it('should capture server replay string error from console error', async () => { it('should capture server replay string error from console error', async () => {
const browser = await next.browser('/ssr') const browser = await next.browser('/ssr')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -229,8 +224,7 @@ describe('app-dir - capture-console-error', () => { ...@@ -229,8 +224,7 @@ describe('app-dir - capture-console-error', () => {
it('should capture server replay error instance from console error', async () => { it('should capture server replay error instance from console error', async () => {
const browser = await next.browser('/ssr-error-instance') const browser = await next.browser('/ssr-error-instance')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
...@@ -276,8 +270,7 @@ describe('app-dir - capture-console-error', () => { ...@@ -276,8 +270,7 @@ describe('app-dir - capture-console-error', () => {
it('should be able to capture rsc logged error', async () => { it('should be able to capture rsc logged error', async () => {
const browser = await next.browser('/rsc') const browser = await next.browser('/rsc')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { import {
getRedboxDescription, getRedboxDescription,
waitForAndOpenRuntimeError, openRedbox,
assertNoRedbox, assertNoRedbox,
retry, retry,
} from 'next-test-utils' } from 'next-test-utils'
...@@ -72,7 +72,7 @@ describe('Dynamic IO Dev Errors', () => { ...@@ -72,7 +72,7 @@ describe('Dynamic IO Dev Errors', () => {
let desc let desc
const browser = await next.browser('/uncached') const browser = await next.browser('/uncached')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
desc = await getRedboxDescription(browser) desc = await getRedboxDescription(browser)
expect(desc).toContain( expect(desc).toContain(
...@@ -80,7 +80,7 @@ describe('Dynamic IO Dev Errors', () => { ...@@ -80,7 +80,7 @@ describe('Dynamic IO Dev Errors', () => {
) )
await browser.refresh() await browser.refresh()
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
desc = await getRedboxDescription(browser) desc = await getRedboxDescription(browser)
expect(desc).toContain( expect(desc).toContain(
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
getRedboxDescription, getRedboxDescription,
hasErrorToast, hasErrorToast,
retry, retry,
waitForAndOpenRuntimeError, openRedbox,
getRedboxSource, getRedboxSource,
} from 'next-test-utils' } from 'next-test-utils'
import { createSandbox } from 'development-sandbox' import { createSandbox } from 'development-sandbox'
...@@ -21,16 +21,12 @@ describe('Dynamic IO Dev Errors', () => { ...@@ -21,16 +21,12 @@ describe('Dynamic IO Dev Errors', () => {
it('should show a red box error on the SSR render', async () => { it('should show a red box error on the SSR render', async () => {
const browser = await next.browser('/error') const browser = await next.browser('/error')
await retry(async () => { await openRedbox(browser)
expect(await hasErrorToast(browser)).toBe(true)
await waitForAndOpenRuntimeError(browser)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot( expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"[ Server ] Error: Route "/error" used \`Math.random()\` outside of \`"use cache"\` and without explicitly calling \`await connection()\` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random"` `"[ Server ] Error: Route "/error" used \`Math.random()\` outside of \`"use cache"\` and without explicitly calling \`await connection()\` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random"`
) )
}) })
})
it('should show a red box error on client navigations', async () => { it('should show a red box error on client navigations', async () => {
const browser = await next.browser('/no-error') const browser = await next.browser('/no-error')
...@@ -39,27 +35,19 @@ describe('Dynamic IO Dev Errors', () => { ...@@ -39,27 +35,19 @@ describe('Dynamic IO Dev Errors', () => {
await browser.elementByCss("[href='/error']").click() await browser.elementByCss("[href='/error']").click()
await retry(async () => { await openRedbox(browser)
expect(await hasErrorToast(browser)).toBe(true)
await waitForAndOpenRuntimeError(browser)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot( expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"[ Server ] Error: Route "/error" used \`Math.random()\` outside of \`"use cache"\` and without explicitly calling \`await connection()\` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random"` `"[ Server ] Error: Route "/error" used \`Math.random()\` outside of \`"use cache"\` and without explicitly calling \`await connection()\` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random"`
) )
}) })
})
// NOTE: when update this snapshot, use `pnpm build` in packages/next to avoid next source code get mapped to source. // NOTE: when update this snapshot, use `pnpm build` in packages/next to avoid next source code get mapped to source.
it('should display error when component accessed data without suspense boundary', async () => { it('should display error when component accessed data without suspense boundary', async () => {
const outputIndex = next.cliOutput.length const outputIndex = next.cliOutput.length
const browser = await next.browser('/no-accessed-data') const browser = await next.browser('/no-accessed-data')
await retry(async () => { await openRedbox(browser)
expect(await hasErrorToast(browser)).toBe(true)
await waitForAndOpenRuntimeError(browser)
await assertHasRedbox(browser)
})
expect(stripAnsi(next.cliOutput.slice(outputIndex))).toContain( expect(stripAnsi(next.cliOutput.slice(outputIndex))).toContain(
`\nError: Route "/no-accessed-data": ` + `\nError: Route "/no-accessed-data": ` +
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { import { assertHasRedbox, getRedboxSource, openRedbox } from 'next-test-utils'
assertHasRedbox,
getRedboxSource,
waitForAndOpenRuntimeError,
} from 'next-test-utils'
describe('hook-function-names', () => { describe('hook-function-names', () => {
const { next, isTurbopack } = nextTestSetup({ const { next, isTurbopack } = nextTestSetup({
...@@ -15,7 +11,7 @@ describe('hook-function-names', () => { ...@@ -15,7 +11,7 @@ describe('hook-function-names', () => {
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
if (isTurbopack) { if (isTurbopack) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { import {
getRedboxSource, getRedboxSource,
waitForAndOpenRuntimeError, openRedbox,
getStackFramesContent, getStackFramesContent,
} from 'next-test-utils' } from 'next-test-utils'
...@@ -19,7 +19,7 @@ const isOwnerStackEnabled = ...@@ -19,7 +19,7 @@ const isOwnerStackEnabled =
it('should catch invalid element from on rsc component', async () => { it('should catch invalid element from on rsc component', async () => {
const browser = await next.browser('/rsc') const browser = await next.browser('/rsc')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
...@@ -61,7 +61,7 @@ const isOwnerStackEnabled = ...@@ -61,7 +61,7 @@ const isOwnerStackEnabled =
it('should catch invalid element from on ssr client component', async () => { it('should catch invalid element from on ssr client component', async () => {
const browser = await next.browser('/ssr') const browser = await next.browser('/ssr')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { getRedboxSource, waitForAndOpenRuntimeError } from 'next-test-utils' import { getRedboxSource, openRedbox } from 'next-test-utils'
// TODO: When owner stack is enabled by default, remove the condition and only keep one test // TODO: When owner stack is enabled by default, remove the condition and only keep one test
const isOwnerStackEnabled = const isOwnerStackEnabled =
...@@ -60,7 +60,7 @@ async function getStackFramesContent(browser) { ...@@ -60,7 +60,7 @@ async function getStackFramesContent(browser) {
it('should catch invalid element from on rsc component', async () => { it('should catch invalid element from on rsc component', async () => {
const browser = await next.browser('/rsc') const browser = await next.browser('/rsc')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
...@@ -97,7 +97,7 @@ async function getStackFramesContent(browser) { ...@@ -97,7 +97,7 @@ async function getStackFramesContent(browser) {
it('should catch invalid element from on ssr client component', async () => { it('should catch invalid element from on ssr client component', async () => {
const browser = await next.browser('/ssr') const browser = await next.browser('/ssr')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
......
...@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils' ...@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils'
import { import {
assertHasRedbox, assertHasRedbox,
assertNoRedbox, assertNoRedbox,
waitForAndOpenRuntimeError, openRedbox,
getRedboxDescription, getRedboxDescription,
} from 'next-test-utils' } from 'next-test-utils'
...@@ -123,7 +123,7 @@ describe('app-dir - owner-stack', () => { ...@@ -123,7 +123,7 @@ describe('app-dir - owner-stack', () => {
return log.message.includes('Error: browser error') return log.message.includes('Error: browser error')
}).message }).message
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
...@@ -209,8 +209,7 @@ describe('app-dir - owner-stack', () => { ...@@ -209,8 +209,7 @@ describe('app-dir - owner-stack', () => {
it('should capture unhandled promise rejections', async () => { it('should capture unhandled promise rejections', async () => {
const browser = await next.browser('/browser/reject-promise') const browser = await next.browser('/browser/reject-promise')
await waitForAndOpenRuntimeError(browser) await openRedbox(browser)
await assertHasRedbox(browser)
const description = await getRedboxDescription(browser) const description = await getRedboxDescription(browser)
expect(description).toMatchInlineSnapshot(`"string in rejected promise"`) expect(description).toMatchInlineSnapshot(`"string in rejected promise"`)
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
assertHasRedbox, assertHasRedbox,
assertNoRedbox, assertNoRedbox,
waitFor, waitFor,
waitForAndOpenRuntimeError, openRedbox,
getRedboxDescriptionWarning, getRedboxDescriptionWarning,
toggleCollapseComponentStack, toggleCollapseComponentStack,
getRedboxErrorLink, getRedboxErrorLink,
...@@ -124,8 +124,8 @@ export async function createSandbox( ...@@ -124,8 +124,8 @@ export async function createSandbox(
async assertNoRedbox() { async assertNoRedbox() {
return assertNoRedbox(browser) return assertNoRedbox(browser)
}, },
async waitForAndOpenRuntimeError() { async openRedbox() {
return waitForAndOpenRuntimeError(browser) return openRedbox(browser)
}, },
async hasErrorToast() { async hasErrorToast() {
return Boolean(await hasErrorToast(browser)) return Boolean(await hasErrorToast(browser))
......
...@@ -879,8 +879,19 @@ export async function hasErrorToast( ...@@ -879,8 +879,19 @@ export async function hasErrorToast(
}) })
} }
export async function waitForAndOpenRuntimeError(browser: BrowserInterface) { /**
return browser.waitForElementByCss('[data-nextjs-toast]', 5000).click() * Has retried version of {@link hasErrorToast} built-in.
* Success implies {@link assertHasRedbox}.
*/
export async function openRedbox(browser: BrowserInterface): Promise<void> {
try {
browser.waitForElementByCss('[data-nextjs-toast]', 5000).click()
} catch (cause) {
const error = new Error('No Redbox to open.', { cause })
Error.captureStackTrace(error, openRedbox)
throw error
}
await assertHasRedbox(browser)
} }
export function getRedboxHeader(browser: BrowserInterface) { export function getRedboxHeader(browser: BrowserInterface) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment