Unverified Commit 0b58a32c authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] `assert*` -> `waitFor*` when the util is not instant (#85450)

parent cb01c9ea
......@@ -304,7 +304,7 @@ describe('ReactRefreshLogBox-builtins app', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
......
......@@ -34,17 +34,17 @@ describe.skip('ReactRefreshLogBox scss app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
// Syntax error
await session.patch('index.module.scss', `.button { font-size: :5px; }`)
await session.assertHasRedbox()
await session.waitForRedbox()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
// Fix syntax error
await session.patch('index.module.scss', `.button { font-size: 5px; }`)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
test('scss module pure selector error', async () => {
......@@ -69,7 +69,7 @@ describe.skip('ReactRefreshLogBox scss app', () => {
// Checks for selectors that can't be prefixed.
// Selector "button" is not pure (pure selectors must contain at least one local class or id)
await session.patch('index.module.scss', `button { font-size: 5px; }`)
await session.assertHasRedbox()
await session.waitForRedbox()
const source2 = await session.getRedboxSource()
expect(source2).toMatchSnapshot()
})
......
......@@ -265,7 +265,7 @@ describe('ReactRefreshLogBox app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
......@@ -388,7 +388,7 @@ describe('ReactRefreshLogBox app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('hello')
......@@ -452,7 +452,7 @@ describe('ReactRefreshLogBox app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('hello new')
......@@ -477,7 +477,7 @@ describe('ReactRefreshLogBox app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch('index.module.css', `.button`)
......@@ -957,7 +957,7 @@ describe('ReactRefreshLogBox app', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
outdent`
......@@ -985,7 +985,7 @@ describe('ReactRefreshLogBox app', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
outdent`
......@@ -1011,7 +1011,7 @@ describe('ReactRefreshLogBox app', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
outdent`
......@@ -1131,7 +1131,7 @@ describe('ReactRefreshLogBox app', () => {
await retry(async () => {
expect(await getToastErrorCount(browser)).toBe(4)
})
await session.assertNoRedbox()
await session.waitForNoRedbox()
// Add Component error
await session.patch(
......@@ -1363,7 +1363,7 @@ describe('ReactRefreshLogBox app', () => {
expect(await browser.waitForElementByCss('#text').text()).toBe(
'Hello world'
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
// Re-add error
await session.patch(
......@@ -1544,7 +1544,7 @@ describe('ReactRefreshLogBox app', () => {
await retry(async () => {
// Should use `await expect(browser).toDisplayRedbox()`
await session.assertHasRedbox()
await session.waitForRedbox()
})
if (isRspack) {
......@@ -1589,7 +1589,7 @@ describe('ReactRefreshLogBox app', () => {
'index.js',
'export default function Page() {return <p>hello world</p>}'
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
}
......
......@@ -12,7 +12,7 @@ describe('ReactRefreshModule app', () => {
it('should allow any variable names', async () => {
await using sandbox = await createSandbox(next, new Map([]))
const { session } = sandbox
await session.assertNoRedbox()
await session.waitForNoRedbox()
const variables = [
'_a',
......@@ -34,7 +34,7 @@ describe('ReactRefreshModule app', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(next.cliOutput).not.toContain(
`'${variable}' has already been declared`
)
......
......@@ -76,7 +76,7 @@ describe('ReactRefreshRegression app', () => {
)
// Verify no hydration mismatch:
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
// https://github.com/vercel/next.js/issues/13978
......@@ -277,7 +277,7 @@ describe('ReactRefreshRegression app', () => {
`export default function () { throw new Error('boom'); }`
)
await session.assertHasRedbox()
await session.waitForRedbox()
const source = await session.getRedboxSource()
expect(source.split(/\r?\n/g).slice(2).join('\n').replace(/^\n+/, ''))
......@@ -296,7 +296,7 @@ describe('ReactRefreshRegression app', () => {
`export default function Page() { throw new Error('boom'); }`
)
await session.assertHasRedbox()
await session.waitForRedbox()
const source = await session.getRedboxSource()
expect(source.split(/\r?\n/g).slice(2).join('\n').replace(/^\n+/, ''))
......@@ -318,7 +318,7 @@ describe('ReactRefreshRegression app', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
const source = await session.getRedboxSource()
expect(source.split(/\r?\n/g).slice(2).join('\n').replace(/^\n+/, ''))
......@@ -366,7 +366,7 @@ describe('ReactRefreshRegression app', () => {
let didNotReload = await session.patch('app/content.mdx', `Hello Foo!`)
expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(
() => document.querySelector('#content').textContent
......@@ -375,7 +375,7 @@ describe('ReactRefreshRegression app', () => {
didNotReload = await session.patch('app/content.mdx', `Hello Bar!`)
expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(
() => document.querySelector('#content').textContent
......
......@@ -52,12 +52,12 @@ describe('Error overlay - RSC build errors', () => {
await session.patch(pagePath, break2.replace('break 3', '<Hello />'))
await session.patch(pagePath, break2)
await session.assertHasRedbox()
await session.waitForRedbox()
await session.patch(pagePath, break1)
await session.patch(pagePath, originalPage)
await session.assertNoRedbox()
await session.waitForNoRedbox()
}
expect(
......
......@@ -86,7 +86,7 @@ describe('Error overlay - editor links', () => {
expect(loaded).toBe(true)
})
await session.assertHasRedbox()
await session.waitForRedbox()
await clickSourceFile(browser)
await check(() => editorRequestsCount, /1/)
})
......@@ -129,7 +129,7 @@ describe('Error overlay - editor links', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
await clickImportTraceFiles(browser)
await check(() => editorRequestsCount, /4/)
})
......@@ -170,7 +170,7 @@ describe('Error overlay - editor links', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
await clickImportTraceFiles(browser)
await check(() => editorRequestsCount, /3/)
})
......
......@@ -20,7 +20,7 @@ describe('Error overlay - error message urls', () => {
content + '\nexport function getServerSideProps() {}'
)
await session.assertHasRedbox()
await session.waitForRedbox()
const link = await browser.elementByCss(
'[data-nextjs-terminal] a, [data-nextjs-codeframe] a'
......
......@@ -115,7 +115,7 @@ describe('Error recovery app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await check(
() => session.evaluate(() => document.querySelector('p').textContent),
......@@ -384,7 +384,7 @@ describe('Error recovery app', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(await session.hasErrorToast()).toBe(false)
expect(
......@@ -395,7 +395,7 @@ describe('Error recovery app', () => {
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Count: 2')
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(await session.hasErrorToast()).toBe(false)
})
......@@ -472,7 +472,7 @@ describe('Error recovery app', () => {
// TODO-APP: re-enable when error recovery doesn't reload the page.
// expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Hello')
......@@ -566,7 +566,7 @@ describe('Error recovery app', () => {
// TODO-APP: re-enable when error recovery doesn't reload the page.
// expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Hello')
......@@ -868,7 +868,7 @@ describe('Error recovery app', () => {
)
// Expected: this fixes the problem
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
// https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/3#issuecomment-554137262
......
......@@ -3,7 +3,7 @@ import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { outdent } from 'outdent'
import {
assertNoRedbox,
waitForNoRedbox,
getRedboxErrorLink,
getToastErrorCount,
retry,
......@@ -89,7 +89,7 @@ describe('Error overlay for hydration errors in App router', () => {
}
`,
async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('.child').text()).toBe('Value')
}
)
......
......@@ -63,7 +63,7 @@ describe('Error Overlay invalid imports', () => {
const withoutUseClient = content.replace("'use client'", '')
await session.patch(pageFile, withoutUseClient)
await session.assertHasRedbox()
await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./app
......@@ -157,7 +157,7 @@ describe('Error Overlay invalid imports', () => {
const withoutUseClient = content.replace("'use client'", '')
await session.patch(pageFile, withoutUseClient)
await session.assertHasRedbox()
await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/client-only-package
......@@ -249,7 +249,7 @@ describe('Error Overlay invalid imports', () => {
const content = await next.readFile(file)
await session.patch(file, "'use client'\n" + content)
await session.assertHasRedbox()
await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/server-only-package
......
......@@ -24,7 +24,7 @@ describe('Error overlay - RSC build errors', () => {
)
await session.patch(pageFile, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
'"getServerSideProps" is not supported in app/'
)
......@@ -46,14 +46,14 @@ describe('Error overlay - RSC build errors', () => {
'export const metadata'
)
await session.patch(pageFile, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
'You are attempting to export "metadata" from a component marked with "use client", which is disallowed.'
)
// Restore file
await session.patch(pageFile, content)
await session.assertNoRedbox()
await session.waitForNoRedbox()
// Add `generateMetadata` error
uncomment = content.replace(
......@@ -61,14 +61,14 @@ describe('Error overlay - RSC build errors', () => {
'export async function generateMetadata'
)
await session.patch(pageFile, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
'You are attempting to export "generateMetadata" from a component marked with "use client", which is disallowed.'
)
// Fix the error again to test error overlay works with hmr rebuild
await session.patch(pageFile, content)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
it('should throw an error when metadata exports are used together in server components', async () => {
......@@ -86,7 +86,7 @@ describe('Error overlay - RSC build errors', () => {
)
await session.patch(pageFile, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
'"metadata" and "generateMetadata" cannot be exported at the same time, please keep one of them.'
)
......@@ -109,7 +109,7 @@ describe('Error overlay - RSC build errors', () => {
await session.patch(pageFile, uncomment)
await next.patchFile(pageFile, content)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
'"getStaticProps" is not supported in app/'
)
......@@ -127,7 +127,7 @@ describe('Error overlay - RSC build errors', () => {
const uncomment = content.replace("// 'use client'", "'use client'")
await next.patchFile(pageFile, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
'directive must be placed before other expressions'
)
......@@ -148,7 +148,7 @@ describe('Error overlay - RSC build errors', () => {
)
await session.patch(pageFile, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
`You’re importing a class component. It only works in a Client Component`
)
......@@ -170,7 +170,7 @@ describe('Error overlay - RSC build errors', () => {
)
await next.patchFile(file, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
if (isTurbopack) {
// TODO: fix the issue ordering.
// turbopack emits the resolve issue first instead of the transform issue.
......@@ -224,7 +224,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/react-apis/${api.toLowerCase()}`
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
// `Component` has a custom error message
api === 'Component'
......@@ -248,7 +248,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/react-dom-apis/${api.toLowerCase()}`
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
`You're importing a component that needs \`${api}\`. This React Hook only works in a Client Component. To fix, mark the file (or its parent) with the \`"use client"\` directive.`
)
......@@ -272,7 +272,7 @@ describe('Error overlay - RSC build errors', () => {
await session.patch(file, uncomment)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
`You're importing a component that needs "server-only". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.`
)
......@@ -288,7 +288,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/next-cache-in-client/${api.toLowerCase()}`
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
`You're importing a component that needs "${api}". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.`
)
......@@ -305,7 +305,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/next-cache-in-client/${api.toLowerCase()}`
)
const { session } = sandbox
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
})
......@@ -319,7 +319,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/next-root-params/without-flag`
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
if (!isCacheComponentsEnabled) {
expect(await session.getRedboxSource()).toInclude(
`'next/root-params' can only be imported when \`experimental.rootParams\` is enabled.`
......@@ -351,7 +351,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/next-root-params/in-client`
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
`You're importing a component that needs "next/root-params". That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.`
)
......@@ -374,7 +374,7 @@ describe('Error overlay - RSC build errors', () => {
`/server-with-errors/next-root-params/in-client-await-import`
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxSource()).toInclude(
`'next/root-params' cannot be imported from a Client Component module. It should only be used from a Server Component.`
)
......@@ -395,7 +395,7 @@ describe('Error overlay - RSC build errors', () => {
content.replace('() => <p>hello dynamic world</p>', 'undefined')
)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxDescription()).toInclude(
`Element type is invalid. Received a promise that resolves to: undefined. Lazy element type must resolve to a class or function.`
)
......@@ -414,7 +414,7 @@ describe('Error overlay - RSC build errors', () => {
'export default function Error() {}'
)
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
/must be a Client \n| Component/
)
......@@ -464,7 +464,7 @@ describe('Error overlay - RSC build errors', () => {
// Empty file
await session.patch('app/server-with-errors/error-file/error.js', '')
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
/Add the "use client"/
)
......@@ -511,7 +511,7 @@ describe('Error overlay - RSC build errors', () => {
const { session } = sandbox
await session.patch(pagePath, content)
await session.assertHasRedbox()
await session.waitForRedbox()
expect(await session.getRedboxDescription()).toContain(
'Cannot add property x, object is not extensible'
......
......@@ -520,7 +520,7 @@ describe('Error Overlay for server components', () => {
])
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
// In webpack when the message too long it gets truncated with ` | ` with new lines.
// So we need to check for the first part of the message.
const normalizedSource = await session.getRedboxSource()
......@@ -552,7 +552,7 @@ describe('Error Overlay for server components', () => {
])
)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
// In webpack when the message too long it gets truncated with ` | ` with new lines.
// So we need to check for the first part of the message.
const normalizedSource = await session.getRedboxSource()
......
......@@ -36,7 +36,7 @@ describe('ReactRefreshLogBox _app _document', () => {
export default MyApp
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
test('empty _document shows logbox', async () => {
......@@ -83,7 +83,7 @@ describe('ReactRefreshLogBox _app _document', () => {
export default MyDocument
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
test('_app syntax error shows logbox', async () => {
......@@ -186,7 +186,7 @@ describe('ReactRefreshLogBox _app _document', () => {
export default MyApp
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
test('_document syntax error shows logbox', async () => {
......@@ -312,6 +312,6 @@ describe('ReactRefreshLogBox _app _document', () => {
export default MyDocument
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
})
......@@ -310,7 +310,7 @@ describe('ReactRefreshLogBox', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.documentElement.innerHTML)
).toContain('index page')
......
......@@ -33,11 +33,11 @@ describe.skip('ReactRefreshLogBox scss', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
// Syntax error
await session.patch('index.module.scss', `.button { font-size: :5px; }`)
await session.assertHasRedbox()
await session.waitForRedbox()
const source = await session.getRedboxSource()
expect(source).toMatchSnapshot()
})
......@@ -64,7 +64,7 @@ describe.skip('ReactRefreshLogBox scss', () => {
// Checks for selectors that can't be prefixed.
// Selector "button" is not pure (pure selectors must contain at least one local class or id)
await session.patch('index.module.scss', `button { font-size: 5px; }`)
await session.assertHasRedbox()
await session.waitForRedbox()
const source2 = await session.getRedboxSource()
expect(source2).toMatchSnapshot()
})
......
......@@ -425,7 +425,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
......@@ -547,7 +547,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('hello')
......@@ -664,7 +664,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('hello new')
......@@ -689,7 +689,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
// Syntax error
await session.patch('index.module.css', `.button`)
......@@ -829,7 +829,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await browser.elementByCss('button').click()
if (isReact18) {
......@@ -880,7 +880,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await browser.elementByCss('button').click()
if (isReact18) {
......@@ -931,7 +931,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await browser.elementByCss('button').click()
if (isReact18) {
......@@ -982,7 +982,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await browser.elementByCss('button').click()
if (isReact18) {
......@@ -1033,7 +1033,7 @@ describe('ReactRefreshLogBox', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await browser.elementByCss('button').click()
if (isReact18) {
......@@ -1116,7 +1116,7 @@ describe('ReactRefreshLogBox', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
outdent`
......@@ -1166,7 +1166,7 @@ describe('ReactRefreshLogBox', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
outdent`
......@@ -1212,7 +1212,7 @@ describe('ReactRefreshLogBox', () => {
}
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
await session.patch(
'index.js',
outdent`
......
......@@ -11,7 +11,7 @@ describe('ReactRefreshModule', () => {
it('should allow any variable names', async () => {
await using sandbox = await createSandbox(next)
const { session } = sandbox
await session.assertNoRedbox()
await session.waitForNoRedbox()
const variables = [
'_a',
......@@ -30,7 +30,7 @@ describe('ReactRefreshModule', () => {
return null
}`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(next.cliOutput).not.toContain(
`'${variable}' has already been declared`
)
......
......@@ -76,7 +76,7 @@ describe('ReactRefreshRegression', () => {
)
// Verify no hydration mismatch:
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
// https://github.com/vercel/next.js/issues/13978
......@@ -341,7 +341,7 @@ describe('ReactRefreshRegression', () => {
let didNotReload = await session.patch('pages/mdx.mdx', `Hello Foo!`)
expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(
() => document.querySelector('#__next').textContent
......@@ -350,7 +350,7 @@ describe('ReactRefreshRegression', () => {
didNotReload = await session.patch('pages/mdx.mdx', `Hello Bar!`)
expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(
() => document.querySelector('#__next').textContent
......
......@@ -122,7 +122,7 @@ describe('pages/ error recovery', () => {
/Count: 1/
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
test('logbox: can recover from a event handler error', async () => {
......@@ -189,7 +189,7 @@ describe('pages/ error recovery', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
......@@ -199,7 +199,7 @@ describe('pages/ error recovery', () => {
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Count: 2')
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
it('logbox: can recover from a component error', async () => {
......@@ -342,7 +342,7 @@ describe('pages/ error recovery', () => {
)
expect(didNotReload).toBe(true)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('Hello')
......@@ -725,7 +725,7 @@ describe('pages/ error recovery', () => {
)
// Expected: this fixes the problem
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
// https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/3#issuecomment-554150098
......
......@@ -141,7 +141,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
expect(await browser.elementByCss('.child').text()).toBe('Value')
})
......@@ -1175,6 +1175,6 @@ describe('Error overlay for hydration errors in Pages router', () => {
)
const { session } = sandbox
// FIXME: Should have a redbox just like with App router
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
})
......@@ -46,7 +46,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
/That only works in a Server Component/
)
......@@ -130,7 +130,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
/That only works in a Server Component/
)
......@@ -216,7 +216,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
/That only works in a Server Component/
)
......@@ -311,7 +311,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
await using sandbox = await createSandbox(next, files)
const { session } = sandbox
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
/That only works in a Server Component/
)
......@@ -403,7 +403,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
`
)
await session.assertHasRedbox()
await session.waitForRedbox()
await expect(session.getRedboxSource()).resolves.toMatch(
`You're importing a component that needs "${api}". That only works in a Server Component which is not supported in the pages/ directory.`
)
......@@ -427,7 +427,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
`
)
await session.assertNoRedbox()
await session.waitForNoRedbox()
})
})
})
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
import { waitForHydration } from 'development-sandbox'
describe('basic app-dir tests', () => {
......@@ -12,6 +12,6 @@ describe('basic app-dir tests', () => {
await browser.refresh()
await waitForHydration(browser)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
......@@ -2,7 +2,7 @@ import { nextTestSetup } from 'e2e-utils'
import {
getRedboxDescription,
openRedbox,
assertNoRedbox,
waitForNoRedbox,
retry,
} from 'next-test-utils'
......@@ -13,11 +13,11 @@ describe('Cache Components Dev Errors', () => {
it('should not show a red box error on the SSR render', async () => {
const browser = await next.browser('/cached')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
let latestValue = await browser.elementByCss('#value').text()
await browser.refresh()
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
let priorValue = latestValue
latestValue = await browser.elementByCss('#value').text()
......@@ -25,7 +25,7 @@ describe('Cache Components Dev Errors', () => {
await browser.elementByCss('#refresh').click()
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
let priorValue = latestValue
latestValue = await browser.elementByCss('#value').text()
expect(latestValue).not.toBe(priorValue)
......@@ -33,7 +33,7 @@ describe('Cache Components Dev Errors', () => {
await browser.elementByCss('#refresh').click()
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
let priorValue = latestValue
latestValue = await browser.elementByCss('#value').text()
expect(latestValue).not.toBe(priorValue)
......@@ -45,7 +45,7 @@ describe('Cache Components Dev Errors', () => {
// await browser.elementByCss('#reload').click()
// await retry(async () => {
// await assertNoRedbox(browser)
// await waitForNoRedbox(browser)
// let priorValue = latestValue
// latestValue = await browser.elementByCss('#value').text()
// expect(latestValue).toBe(priorValue)
......@@ -53,7 +53,7 @@ describe('Cache Components Dev Errors', () => {
// await browser.elementByCss('#reload').click()
// await retry(async () => {
// await assertNoRedbox(browser)
// await waitForNoRedbox(browser)
// let priorValue = latestValue
// latestValue = await browser.elementByCss('#value').text()
// expect(latestValue).toBe(priorValue)
......@@ -61,7 +61,7 @@ describe('Cache Components Dev Errors', () => {
// await browser.elementByCss('#refresh').click()
// await retry(async () => {
// await assertNoRedbox(browser)
// await waitForNoRedbox(browser)
// let priorValue = latestValue
// latestValue = await browser.elementByCss('#value').text()
// expect(latestValue).not.toBe(priorValue)
......
import stripAnsi from 'strip-ansi'
import { nextTestSetup } from 'e2e-utils'
import {
assertNoRedbox,
assertNoErrorToast,
waitForNoRedbox,
waitForNoErrorToast,
hasErrorToast,
retry,
} from 'next-test-utils'
......@@ -44,7 +44,7 @@ describe('Cache Components Dev Errors', () => {
})
await browser.elementByCss("[href='/error']").click()
await assertNoErrorToast(browser)
await waitForNoErrorToast(browser)
await browser.loadPage(`${next.url}/error`)
......@@ -175,6 +175,6 @@ describe('Cache Components Dev Errors', () => {
}
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('Cache Components Fallback Validation', () => {
const { isTurbopack, next } = nextTestSetup({
......@@ -12,24 +12,24 @@ describe('Cache Components Fallback Validation', () => {
const browser = await next.browser(
'/complete/prerendered/wrapped/prerendered'
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/prerendered/wrapped/novel`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/novel/wrapped/novel`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(
`${next.url}/complete/prerendered/unwrapped/prerendered`
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/prerendered/unwrapped/novel`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/novel/unwrapped/novel`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should warn about missing Suspense when accessing params if static params are partially known at build time', async () => {
......@@ -38,13 +38,13 @@ describe('Cache Components Fallback Validation', () => {
const browser = await next.browser(
'/partial/prerendered/wrapped/prerendered'
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/partial/prerendered/wrapped/novel`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/partial/novel/wrapped/novel`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.loadPage(
`${next.url}/partial/prerendered/unwrapped/prerendered`
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, assertNoConsoleErrors } from 'next-test-utils'
import { waitForNoRedbox, assertNoConsoleErrors } from 'next-test-utils'
describe('app-dir - capture-console-error-owner-stack', () => {
const { next } = nextTestSetup({
......@@ -122,7 +122,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const browser = await next.browser('/browser/error-event')
await browser.elementByCss('button').click()
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await assertNoConsoleErrors(browser)
})
})
import { nextTestSetup } from 'e2e-utils'
import {
assertHasDevToolsIndicator,
waitForDevToolsIndicator,
assertNoDevToolsIndicator,
openDevToolsIndicatorPopover,
toggleDevToolsIndicatorPopover,
waitFor,
} from 'next-test-utils'
......@@ -19,7 +19,7 @@ describe('dev indicator - Hide DevTools Button', () => {
it('should show the dev indicator when the server is manually restarted', async () => {
const browser = await next.browser('/')
await openDevToolsIndicatorPopover(browser)
await toggleDevToolsIndicatorPopover(browser)
await browser.elementByCss('[data-preferences]').click()
await browser.elementByCss('[data-hide-dev-tools]').click()
......@@ -30,13 +30,13 @@ describe('dev indicator - Hide DevTools Button', () => {
const browser2 = await next.browser('/')
await browser2.refresh()
await assertHasDevToolsIndicator(browser2)
await waitForDevToolsIndicator(browser2)
})
it('should still hide the dev indicator after reloading the page', async () => {
const browser = await next.browser('/')
await openDevToolsIndicatorPopover(browser)
await toggleDevToolsIndicatorPopover(browser)
await browser.elementByCss('[data-preferences]').click()
await browser.elementByCss('[data-hide-dev-tools]').click()
......@@ -52,7 +52,7 @@ describe('dev indicator - Hide DevTools Button', () => {
const browser = await next.browser('/')
await openDevToolsIndicatorPopover(browser)
await toggleDevToolsIndicatorPopover(browser)
await browser.elementByCss('[data-preferences]').click()
await browser.elementByCss('[data-hide-dev-tools]').click()
......@@ -62,6 +62,6 @@ describe('dev indicator - Hide DevTools Button', () => {
await waitFor(COOLDOWN)
await browser.refresh()
await assertHasDevToolsIndicator(browser)
await waitForDevToolsIndicator(browser)
})
})
import { nextTestSetup } from 'e2e-utils'
import { assertStaticIndicator, retry } from 'next-test-utils'
import { waitForStaticIndicator } from 'next-test-utils'
describe('app dir dev indicator - route type', () => {
const { next } = nextTestSetup({
......@@ -9,9 +9,7 @@ describe('app dir dev indicator - route type', () => {
it('should have route type as static by default for static page', async () => {
const browser = await next.browser('/')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
it('should have route type as dynamic when changing to dynamic page', async () => {
......@@ -24,9 +22,7 @@ describe('app dir dev indicator - route type', () => {
)
try {
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
} finally {
await next.patchFile('app/page.tsx', origContent)
}
......@@ -43,9 +39,7 @@ describe('app dir dev indicator - route type', () => {
const browser = await next.browser('/')
try {
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
} finally {
await next.patchFile('app/page.tsx', origContent)
}
......@@ -56,6 +50,6 @@ describe('app dir dev indicator - route type', () => {
await browser.waitForElementByCss('#ready')
await assertStaticIndicator(browser, 'Dynamic')
await waitForStaticIndicator(browser, 'Dynamic')
})
})
import type { Playwright } from '../../../lib/next-webdriver'
import { assertHasDevToolsIndicator } from 'next-test-utils'
import { waitForDevToolsIndicator } from 'next-test-utils'
export async function getDevIndicatorPosition(browser: Playwright) {
// assert before eval() to prevent race condition
await assertHasDevToolsIndicator(browser)
await waitForDevToolsIndicator(browser)
const style = await browser.eval(() => {
return (
......
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, assertNoRedbox } from 'next-test-utils'
import { waitForRedbox, waitForNoRedbox } from 'next-test-utils'
describe('develop - app-dir - edge errros hmr', () => {
const { next } = nextTestSetup({
......@@ -14,11 +14,11 @@ describe('develop - app-dir - edge errros hmr', () => {
return content.replace('{/* < */}', '<') // uncomment
})
await assertHasRedbox(browser)
await waitForRedbox(browser)
await next.patchFile('app/comp.server.js', clientComponentSource)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should recover from build errors when client component error', async () => {
......@@ -29,10 +29,10 @@ describe('develop - app-dir - edge errros hmr', () => {
return content.replace('{/* < */}', '<') // uncomment
})
await assertHasRedbox(browser)
await waitForRedbox(browser)
await next.patchFile('app/comp.client.js', clientComponentSource)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
/* eslint-env jest */
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('app-dir - async-client-component', () => {
const { next } = nextTestSetup({
......@@ -37,7 +37,7 @@ describe('app-dir - async-client-component', () => {
it('app router server component async module', async () => {
const browser = await next.browser('/server')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#app-router-value').text()).toBe('hello')
})
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
waitForRedbox,
getStackFramesContent,
toggleCollapseCallStackFrames,
} from 'next-test-utils'
......@@ -12,7 +12,7 @@ describe('error-ignored-frames', () => {
it('should be able to collapse ignored frames in server component', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const defaultStack = await getStackFramesContent(browser)
expect(defaultStack).toMatchInlineSnapshot(`"at Page (app/page.tsx (2:9))"`)
......@@ -29,7 +29,7 @@ describe('error-ignored-frames', () => {
it('should be able to collapse ignored frames in client component', async () => {
const browser = await next.browser('/client')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const defaultStack = await getStackFramesContent(browser)
expect(defaultStack).toMatchInlineSnapshot(
......@@ -48,7 +48,7 @@ describe('error-ignored-frames', () => {
it('should be able to collapse ignored frames in interleaved call stack', async () => {
const browser = await next.browser('/interleaved')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const defaultStack = await getStackFramesContent(browser)
if (isTurbopack) {
......@@ -75,7 +75,7 @@ describe('error-ignored-frames', () => {
it('should be able to collapse pages router ignored frames', async () => {
const browser = await next.browser('/pages')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const defaultStack = await getStackFramesContent(browser)
expect(defaultStack).toMatchInlineSnapshot(
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
waitForRedbox,
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
......@@ -13,7 +13,7 @@ describe.skip('externalize-node-binary-browser-error', () => {
it('should error when import node binary on browser side', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......
import { join } from 'path'
import { nextTestSetup, FileRef } from 'e2e-utils'
import { assertHasRedbox, assertNoRedbox } from 'next-test-utils'
import { waitForRedbox, waitForNoRedbox } from 'next-test-utils'
import { waitForHydration } from 'development-sandbox'
describe('hmr-deleted-page', () => {
......@@ -19,12 +19,12 @@ describe('hmr-deleted-page', () => {
await next.deleteFile('app/page/style.css')
await waitForHydration(browser)
await assertHasRedbox(browser)
await waitForRedbox(browser)
await next.deleteFile('app/page')
await waitForHydration(browser)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('h1').text()).toBe('404')
})
})
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('HMR Move File', () => {
const { next } = nextTestSetup({
......@@ -17,7 +17,7 @@ describe('HMR Move File', () => {
content.replace('./button', './button2')
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#hello-world-button').text()).toBe(
'hello world'
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('hmr-parallel-routes', () => {
const { next } = nextTestSetup({
......@@ -15,7 +15,7 @@ describe('hmr-parallel-routes', () => {
content.replace('Bar Page', 'Bar Page Updated')
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#bar').text()).toBe('Bar Page Updated')
......@@ -23,7 +23,7 @@ describe('hmr-parallel-routes', () => {
content.replace('Foo Page', 'Foo Page Updated')
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#foo').text()).toBe('Foo Page Updated')
})
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('hmr-app-and-pages', () => {
const { next } = nextTestSetup({
......@@ -21,7 +21,7 @@ describe('hmr-app-and-pages', () => {
)
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(
await browser.elementByCss('body').getComputedCss('background-color')
).toEqual('rgb(255, 0, 0)')
......@@ -41,7 +41,7 @@ describe('hmr-app-and-pages', () => {
)
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(
await browser.elementByCss('body').getComputedCss('background-color')
).toEqual('rgb(255, 255, 255)')
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
// This tests file symlinks, but not directory symlinks. Directory symlinks are
// known to break route manifest generation:
......@@ -21,7 +21,7 @@ describe('HMR symlinks', () => {
(content) => content.replace('symlink target', 'updated symlink target'),
async () => {
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('h1').text()).toBe(
'This is the updated symlink target'
)
......@@ -47,7 +47,7 @@ describe('HMR symlinks', () => {
'app/symlink-link/page.tsx'
)
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('h1').text()).toBe(
'This is the second symlink target'
)
......@@ -77,7 +77,7 @@ describe('HMR symlinks', () => {
'app/symlink-link/page.tsx'
)
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('h1').text()).toBe(
'This is the second symlink target'
)
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getToastErrorCount,
hasErrorToast,
retry,
......@@ -12,7 +12,7 @@ describe('app-dir - missing required html tags', () => {
it('should display correct error count in dev indicator', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
retry(async () => {
expect(await hasErrorToast(browser)).toBe(true)
})
......@@ -22,7 +22,7 @@ describe('app-dir - missing required html tags', () => {
it('should show error overlay', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
await expect(browser).toDisplayRedbox(`
{
"description": "Missing <html> and <body> tags in the root layout.
......@@ -93,7 +93,7 @@ describe('app-dir - missing required html tags', () => {
retry(() => expect(reloaded).toBe(true), 10_000),
])
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('p').text()).toBe('hello world')
// Reintroduce the bug, but only missing html tag
......@@ -105,6 +105,6 @@ describe('app-dir - missing required html tags', () => {
)
// TODO(NDX-768): Should show "missing tags" error
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
/* eslint-env jest */
import { nextTestSetup } from 'e2e-utils'
import * as Log from './basic/utils/log'
import { assertHasRedbox, getRedboxSource } from '../../../lib/next-test-utils'
import { waitForRedbox, getRedboxSource } from '../../../lib/next-test-utils'
import { join } from 'path'
describe('after() - invalid usages', () => {
......@@ -25,7 +25,7 @@ describe('after() - invalid usages', () => {
it('errors at compile time when used in a client module', async () => {
const session = await next.browser('/invalid-in-client')
await assertHasRedbox(session)
await waitForRedbox(session)
expect(await getRedboxSource(session)).toMatch(
/You're importing a component that needs "?after"?\. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component\./
)
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
// These stacks are not sourcemapped and therefore not ignore-listed.
// Feel free to update internal frames in assertions.
......@@ -86,7 +86,7 @@ describe('app-dir - owner-stack', () => {
it('should log stitched error for browser caught errors', async () => {
const browser = await next.browser('/browser/caught')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
const logs = await browser.log()
const errorLog = logs.find((log) => {
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
waitForRedbox,
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
......@@ -12,7 +12,7 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => {
it('should error when use dynamic ssr:false in server component', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
......@@ -40,7 +40,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/app-code/react-dom-server-browser-explicit'
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
if (isTurbopack) {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{
......@@ -108,7 +108,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/app-code/react-dom-server-edge-explicit'
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
if (isTurbopack) {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{
......@@ -258,7 +258,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/app-code/react-dom-server-node-explicit'
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......@@ -315,7 +315,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/app-code/react-dom-server-node-implicit'
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......@@ -398,7 +398,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/library-code/react-dom-server-browser-explicit'
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......@@ -455,7 +455,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/library-code/react-dom-server-edge-explicit'
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
if (isTurbopack) {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{
......@@ -527,7 +527,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/library-code/react-dom-server-edge-implicit'
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
if (isTurbopack) {
expect(await browser.elementByCss('main').text()).toMatchInlineSnapshot(`
"{
......@@ -599,7 +599,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/library-code/react-dom-server-node-explicit'
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......@@ -656,7 +656,7 @@ describe('react-dom/server in React Server environment', () => {
'/exports/library-code/react-dom-server-node-implicit'
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, hasErrorToast } from 'next-test-utils'
import { waitForNoRedbox, hasErrorToast } from 'next-test-utils'
describe('ssr-only-error', () => {
const { next } = nextTestSetup({
......@@ -30,7 +30,7 @@ describe('ssr-only-error', () => {
pushErrorAsConsoleLog: true,
})
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await hasErrorToast(browser)).toBe(false)
const text = await browser.elementByCss('body').text()
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from '../../../lib/next-test-utils'
import { waitForNoRedbox } from '../../../lib/next-test-utils'
describe('use-cache-errors', () => {
const { next } = nextTestSetup({
......@@ -12,7 +12,7 @@ describe('use-cache-errors', () => {
// statement (`var _s = __turbopack_context__.k.signature`) does not
// interfere with our "use cache" directive misplacement detection.
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should show a runtime error when calling the incorrectly used cache function', async () => {
......
import { join } from 'path'
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
// This is implemented in Turbopack, but Turbopack doesn't log the module count.
;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
......@@ -27,7 +27,7 @@ import { assertNoRedbox } from 'next-test-utils'
expect($('#typography').text()).toContain('typography')
const browser = await next.browser('/mui')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
}
......
import { join } from 'path'
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('optimizePackageImports - mui', () => {
const { next } = nextTestSetup({
......@@ -20,6 +20,6 @@ describe('optimizePackageImports - mui', () => {
it('should work', async () => {
// Without barrel optimization, the reproduction breaks.
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
......@@ -3,7 +3,7 @@
import { join } from 'path'
import webdriver from 'next-webdriver'
import { createNext, FileRef } from 'e2e-utils'
import { assertNoRedbox, check } from 'next-test-utils'
import { waitForNoRedbox, check } from 'next-test-utils'
import { NextInstance } from 'e2e-utils'
const installCheckVisible = (browser) => {
......@@ -292,7 +292,7 @@ describe('GS(S)P Server-Side Change Reloading', () => {
`)
await next.patchFile(page, originalContent)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
} finally {
await next.patchFile(page, originalContent)
}
......@@ -333,7 +333,7 @@ describe('GS(S)P Server-Side Change Reloading', () => {
expect(next.cliOutput).toMatch(/custom oops/)
await next.patchFile(page, originalContent)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
} finally {
await next.patchFile(page, originalContent)
}
......
import {
assertHasRedbox,
waitForRedbox,
getBrowserBodyText,
retry,
waitFor,
......@@ -57,7 +57,7 @@ export function runBasicHmrTest(nextConfig: {
'pages/auto-export-is-ready.js',
(content) => `import hello from 'non-existent'\n` + content,
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
await waitFor(3000)
outputLength = next.cliOutput.length
}
......
import { join } from 'path'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getBrowserBodyText,
getRedboxHeader,
getRedboxDescription,
......@@ -156,7 +156,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
join('pages', 'hmr', 'about2.js'),
(content) => content.replace('</div>', 'div'),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
const source = next.normalizeTestDirContent(
await getRedboxSource(browser)
)
......@@ -247,7 +247,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
// Ensure dev server has time to break:
await new Promise((resolve) => setTimeout(resolve, 2000))
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toContain(
"Expected '</', got '<eof>'"
)
......@@ -275,7 +275,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
join('pages', 'hmr', 'about3.js'),
(content) => content.replace('export', 'aa=20;\nexport'),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxHeader(browser)).toMatch(/aa is not defined/)
}
)
......@@ -304,7 +304,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
'throw new Error("an-expected-error");\nreturn'
),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatch(/an-expected-error/)
}
)
......@@ -333,7 +333,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
'export default {};\nexport const fn ='
),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"The default export is not a React Component in page: "/hmr/about5""`
)
......@@ -364,7 +364,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
'export default () => /search/;\nexport const fn ='
),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
// TODO: Replace this when webpack 5 is the default
expect(await getRedboxHeader(browser)).toMatch(
`Objects are not valid as a React child (found: [object RegExp]). If you meant to render a collection of children, use an array instead.`
......@@ -397,7 +397,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
'export default undefined;\nexport const fn ='
),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"The default export is not a React Component in page: "/hmr/about7""`
)
......@@ -409,7 +409,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
/This is the about page/
)
})
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should recover after webpack parse error in an imported file', async () => {
......@@ -429,7 +429,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
'import "../../components/parse-error.xyz"\nexport default'
),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxHeader(browser)).toMatch('Build Error')
if (process.env.IS_TURBOPACK_TEST) {
......@@ -486,7 +486,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
/This is the about page/
)
})
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should recover after loader parse error in an imported file', async () => {
......@@ -506,7 +506,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
'import "../../components/parse-error.js"\nexport default'
),
async () => {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxHeader(browser)).toMatch('Build Error')
let redboxSource = await getRedboxSource(browser)
......@@ -585,7 +585,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
/This is the about page/
)
})
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should recover from errors in getInitialProps in client', async () => {
......@@ -594,7 +594,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
const errorContent = await next.readFile(erroredPage)
await browser.elementByCss('#error-in-gip-link').click()
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"an-expected-error-in-gip"`
)
......@@ -626,7 +626,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
it('should recover after an error reported via SSR', async () => {
const browser = await next.browser(basePath + '/hmr/error-in-gip')
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot(
`"an-expected-error-in-gip"`
)
......
......@@ -2,7 +2,7 @@ import { join } from 'path'
import cheerio from 'cheerio'
import webdriver from 'next-webdriver'
import { createNext, FileRef } from 'e2e-utils'
import { assertNoRedbox, renderViaHTTP, check } from 'next-test-utils'
import { waitForNoRedbox, renderViaHTTP, check } from 'next-test-utils'
import { NextInstance } from 'e2e-utils'
const customDocumentGipContent = `\
......@@ -170,7 +170,7 @@ describe('next/dynamic', () => {
try {
browser = await webdriver(next.url, basePath + '/dynamic/no-ssr')
await check(() => browser.elementByCss('body').text(), /navigator/)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
} finally {
if (browser) {
await browser.close()
......@@ -183,7 +183,7 @@ describe('next/dynamic', () => {
try {
browser = await webdriver(next.url, basePath + '/dynamic/no-ssr-esm')
await check(() => browser.elementByCss('body').text(), /esm.mjs/)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
} finally {
if (browser) {
await browser.close()
......
import fs from 'fs-extra'
import webdriver from 'next-webdriver'
import { assertNoRedbox, check, findPort } from 'next-test-utils'
import { waitForNoRedbox, check, findPort } from 'next-test-utils'
import { NextInstance } from 'e2e-utils'
import { createNext } from 'e2e-utils'
import stripAnsi from 'strip-ansi'
......@@ -42,7 +42,7 @@ describe.skip('Project Directory Renaming', () => {
await check(async () => {
return (await browser.eval('window.beforeNav')) === 1 ? 'pending' : 'done'
}, 'done')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
try {
// should still HMR correctly
......
......@@ -2,7 +2,7 @@ import { FileRef } from 'e2e-utils'
import { Playwright } from 'next-webdriver'
import { nextTestSetup } from 'e2e-utils'
import { join } from 'path'
import { assertHasDevToolsIndicator, retry } from 'next-test-utils'
import { waitForDevToolsIndicator, retry } from 'next-test-utils'
describe('client-dev-overlay', () => {
const { next, isTurbopack } = nextTestSetup({
......@@ -124,8 +124,8 @@ describe('client-dev-overlay', () => {
it('should nudge to use Turbopack unless Turbopack is disabled', async () => {
const browser = await next.browser('/')
// Don't use openDevToolsIndicatorPopover because this is asserting something in the old dev tools menu which isn't preset yet in the new UI.
const devToolsIndicator = await assertHasDevToolsIndicator(browser)
// Don't use toggleDevToolsIndicatorPopover because this is asserting something in the old dev tools menu which isn't preset yet in the new UI.
const devToolsIndicator = await waitForDevToolsIndicator(browser)
try {
await devToolsIndicator.click()
} catch (cause) {
......@@ -175,7 +175,7 @@ describe('client-dev-overlay with Cache Components', () => {
it('should show Cache Components as enabled in the devtools menu', async () => {
const browser = await next.browser('/')
const devToolsIndicator = await assertHasDevToolsIndicator(browser)
const devToolsIndicator = await waitForDevToolsIndicator(browser)
try {
await devToolsIndicator.click()
} catch (cause) {
......
import { nextTestSetup } from 'e2e-utils'
import { assertStaticIndicator, retry } from 'next-test-utils'
import { waitForStaticIndicator } from 'next-test-utils'
const withCacheComponents = process.env.__NEXT_CACHE_COMPONENTS === 'true'
......@@ -12,39 +12,29 @@ describe('dev indicator - route type', () => {
it('should update when going from dynamic -> static', async () => {
const browser = await next.browser('/pages/gssp')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
// validate static -> dynamic updates
await browser.elementByCss("[href='/pages']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
it('should update when going from static -> dynamic', async () => {
const browser = await next.browser('/pages')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
// validate static -> dynamic updates
await browser.elementByCss("[href='/pages/gssp']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
it('should be marked dynamic on first load', async () => {
const browser = await next.browser('/pages/gssp')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
})
......@@ -52,37 +42,27 @@ describe('dev indicator - route type', () => {
it('should be marked dynamic on first load', async () => {
const browser = await next.browser('/pages/gip')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
it('should update when going from dynamic -> static', async () => {
const browser = await next.browser('/pages/gip')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
await browser.elementByCss("[href='/pages']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
it('should update when going from static -> dynamic', async () => {
const browser = await next.browser('/pages')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
await browser.elementByCss("[href='/pages/gip']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
})
......@@ -90,32 +70,24 @@ describe('dev indicator - route type', () => {
it('should be marked static on first load', async () => {
const browser = await next.browser('/pages/pregenerated')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
it('should update when going from dynamic -> static', async () => {
const browser = await next.browser('/pages/gssp')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
await browser.elementByCss("[href='/pages/pregenerated']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
})
it('should have route type as static by default for static page', async () => {
const browser = await next.browser('/pages')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
describe('with App Router', () => {
......@@ -124,18 +96,16 @@ describe('dev indicator - route type', () => {
describe('with Cache Components enabled', () => {
it('should not show a static indicator', async () => {
const browser = await next.browser('/app/static-indicator/dynamic')
await assertStaticIndicator(browser, undefined)
await waitForStaticIndicator(browser, undefined)
})
it('should still show a static indicator when navigating to a Pages Router page', async () => {
const browser = await next.browser('/app/static-indicator/dynamic')
await assertStaticIndicator(browser, undefined)
await waitForStaticIndicator(browser, undefined)
await browser.elementByCss("[href='/pages']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
})
} else {
......@@ -143,25 +113,19 @@ describe('dev indicator - route type', () => {
it('should be marked dynamic on first load', async () => {
const browser = await next.browser('/app/static-indicator/dynamic')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
it('should update when going from dynamic -> static', async () => {
const browser = await next.browser('/app/static-indicator/dynamic')
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
await browser
.elementByCss("[href='/app/static-indicator/static']")
.click()
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
})
}
......@@ -172,18 +136,16 @@ describe('dev indicator - route type', () => {
describe('with Cache Components enabled', () => {
it('should not show a static indicator', async () => {
const browser = await next.browser('/app/static-indicator/static')
await assertStaticIndicator(browser, undefined)
await waitForStaticIndicator(browser, undefined)
})
it('should still show a static indicator when navigating to a Pages Router page', async () => {
const browser = await next.browser('/app/static-indicator/static')
await assertStaticIndicator(browser, undefined)
await waitForStaticIndicator(browser, undefined)
await browser.elementByCss("[href='/pages/gssp']").click()
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
})
} else {
......@@ -191,25 +153,19 @@ describe('dev indicator - route type', () => {
it('should be marked static on first load', async () => {
const browser = await next.browser('/app/static-indicator/static')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
})
it('should update when going from static -> dynamic', async () => {
const browser = await next.browser('/app/static-indicator/static')
await retry(async () => {
await assertStaticIndicator(browser, 'Static')
})
await waitForStaticIndicator(browser, 'Static')
await browser
.elementByCss("[href='/app/static-indicator/dynamic']")
.click()
await retry(async () => {
await assertStaticIndicator(browser, 'Dynamic')
})
await waitForStaticIndicator(browser, 'Dynamic')
})
})
}
......
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox } from 'next-test-utils'
import { waitForRedbox } from 'next-test-utils'
describe('DevErrorOverlay', () => {
const { next } = nextTestSetup({
......@@ -86,7 +86,7 @@ describe('DevErrorOverlay', () => {
},
})
await assertHasRedbox(browser)
await waitForRedbox(browser)
await browser.waitForIdleNetwork()
// Verify woff2 files were requested and loaded successfully
......@@ -99,7 +99,7 @@ describe('DevErrorOverlay', () => {
it('should load dev overlay styles successfully', async () => {
const browser = await next.browser('/hydration-error')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = browser.locateRedbox()
// check the data-nextjs-dialog-header="true" DOM element styles under redbox is applied
......
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
check,
renderViaHTTP,
getRedboxSource,
......@@ -82,7 +82,7 @@ describe('jsconfig-path-reloading', () => {
)}`
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toContain('"@lib/second-data"')
await next.patchFile(
......@@ -103,7 +103,7 @@ describe('jsconfig-path-reloading', () => {
)
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
const html2 = await browser.eval('document.documentElement.innerHTML')
expect(html2).toContain('first button')
......@@ -158,7 +158,7 @@ describe('jsconfig-path-reloading', () => {
indexContent.replace('@mybutton', '@myotherbutton')
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await check(async () => {
const html2 = await browser.eval('document.documentElement.innerHTML')
......
import { assertNoRedbox, check, getDistDir, retry } from 'next-test-utils'
import { waitForNoRedbox, check, getDistDir, retry } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
import { nextTestSetup } from 'e2e-utils'
......@@ -98,7 +98,7 @@ describe('middleware - development errors', () => {
await next.patchFile('middleware.js', `export default function () {}`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
......@@ -149,7 +149,7 @@ describe('middleware - development errors', () => {
it('does not render the error', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#page-title')).toBeTruthy()
})
})
......@@ -269,7 +269,7 @@ describe('middleware - development errors', () => {
expect(next.cliOutput.slice(lengthOfLogs)).toContain('GET / 200')
}, 10000) // middleware rebuild takes a while in CI
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
......@@ -375,7 +375,7 @@ describe('middleware - development errors', () => {
await next.patchFile('middleware.js', `export default function () {}`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
......@@ -410,7 +410,7 @@ describe('middleware - development errors', () => {
it('does not render the error', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#page-title')).toBeTruthy()
})
})
......@@ -448,7 +448,7 @@ describe('middleware - development errors', () => {
it('does not render the error', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#page-title')).toBeTruthy()
})
})
......@@ -529,7 +529,7 @@ describe('middleware - development errors', () => {
await next.patchFile('middleware.js', `export default function () {}`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#page-title')).toBeTruthy()
})
})
......@@ -557,7 +557,7 @@ describe('middleware - development errors', () => {
it('renders the error correctly and recovers', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await next.patchFile('middleware.js', `export default function () }`)
......@@ -615,7 +615,7 @@ describe('middleware - development errors', () => {
await next.patchFile('middleware.js', `export default function () {}`)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('#page-title')).toBeTruthy()
})
})
......
......@@ -3,8 +3,8 @@ import { NextInstance } from 'e2e-utils'
import { join } from 'path'
import webdriver from 'next-webdriver'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getRedboxSource,
} from 'next-test-utils'
......@@ -36,7 +36,7 @@ export default function Page() {
`
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"app/page.js
\`next/font\` error:
......@@ -44,7 +44,7 @@ export default function Page() {
`)
await next.patchFile('app/page.js', content)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it("should show a module not found error if local font file can' be resolved", async () => {
......@@ -64,7 +64,7 @@ export default function Page() {
`
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
const sourceLines = (await getRedboxSource(browser)).split('\n')
// Should display the file name correctly
......@@ -75,6 +75,6 @@ export default function Page() {
)
await next.patchFile('app/page.js', content)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource } from 'next-test-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
import webdriver from 'next-webdriver'
import { join } from 'path'
......@@ -18,7 +18,7 @@ describe('font-loader-in-document-error', () => {
test('next/font inside _document', async () => {
const browser = await webdriver(next.url, '/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
if (process.env.IS_TURBOPACK_TEST) {
// TODO: Turbopack doesn't include pages/
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
......
/* eslint-env jest */
import { assertNoRedbox, waitFor } from 'next-test-utils'
import { waitForNoRedbox, waitFor } from 'next-test-utils'
import path from 'path'
import { nextTestSetup } from 'e2e-utils'
......@@ -22,7 +22,7 @@ describe('Client navigation with foreign history manipulation', () => {
await browser.waitForElementByCss('.nav-about')
await browser.back()
await waitFor(1000)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should ignore history state with an invalid url', async () => {
......@@ -35,7 +35,7 @@ describe('Client navigation with foreign history manipulation', () => {
await browser.waitForElementByCss('.nav-about')
await browser.back()
await waitFor(1000)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should ignore foreign history state with missing properties', async () => {
......@@ -46,6 +46,6 @@ describe('Client navigation with foreign history manipulation', () => {
await browser.waitForElementByCss('.nav-about')
await browser.back()
await waitFor(1000)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
import { nextTestSetup } from 'e2e-utils'
import fs from 'fs-extra'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
import path from 'path'
describe('repeated-dev-edits', () => {
......@@ -25,7 +25,7 @@ describe('repeated-dev-edits', () => {
expect(await browser.elementByCss('p').text()).toBe('version-2')
// Verify no hydration mismatch:
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await next.patchFile(
pagePath,
......@@ -35,11 +35,11 @@ describe('repeated-dev-edits', () => {
expect(await browser.elementByCss('p').text()).toBe('version-3')
// Verify no hydration mismatch:
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.refresh()
// Verify no hydration mismatch:
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource } from 'next-test-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('app dir - css', () => {
const { next, skipped } = nextTestSetup({
......@@ -21,7 +21,7 @@ describe('app dir - css', () => {
it('should use original source points for sass errors', async () => {
const browser = await next.browser('/sass-error')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const source = await getRedboxSource(browser)
// css-loader does not report an error for this case
......
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
check,
renderViaHTTP,
getRedboxSource,
......@@ -82,7 +82,7 @@ describe('tsconfig-path-reloading', () => {
)}`
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toContain("'@lib/second-data'")
await next.patchFile(
......@@ -103,7 +103,7 @@ describe('tsconfig-path-reloading', () => {
)
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
const html2 = await browser.eval('document.documentElement.innerHTML')
expect(html2).toContain('first button')
......@@ -158,7 +158,7 @@ describe('tsconfig-path-reloading', () => {
indexContent.replace('@mybutton', '@myotherbutton')
)
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await check(async () => {
const html2 = await browser.eval('document.documentElement.innerHTML')
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
describe('app-dir - action-in-pages-router', () => {
const { next, isNextStart } = nextTestSetup({
......@@ -17,7 +17,7 @@ describe('app-dir - action-in-pages-router', () => {
.join('')
// This is a fake server action, a simple function so it can still work
expect(browserLogText).toContain('action:foo')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
})
......
import { FileRef, nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
waitForRedbox,
retry,
waitFor,
getRedboxSource,
......@@ -995,7 +995,7 @@ describe('app-dir action handling', () => {
origContent + '\n\nexport const foo = 1'
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toContain(
'Only async functions are allowed to be exported in a "use server" file.'
)
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
describe('app dir', () => {
const { next, isNextDev, isNextStart, skipped } = nextTestSetup({
......@@ -43,7 +43,7 @@ describe('app dir', () => {
})
// It should not have an error
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
// HMR should still work
await next.patchFile(
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, check, getDistDir, retry } from 'next-test-utils'
import { waitForNoRedbox, check, getDistDir, retry } from 'next-test-utils'
async function resolveStreamResponse(response: any, onData?: any) {
let result = ''
......@@ -249,7 +249,7 @@ describe('app dir - external dependency', () => {
expect($('#transpile-cjs-lib').text()).toBe('transpile-cjs-lib')
const browser = await next.browser('/cjs/client')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
it('should export client module references in esm', async () => {
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
import { join } from 'path'
import { createSandbox } from 'development-sandbox'
import { outdent } from 'outdent'
......@@ -70,7 +70,7 @@ describe('app-root-param-getters - simple', () => {
'This page could not be found.'
)
if (isNextDev) {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
}
})
......
import { nextTestSetup } from 'e2e-utils'
import { join } from 'path'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('app-root-param-getters - cache - at runtime', () => {
const { next, isNextDev, skipped } = nextTestSetup({
......@@ -72,7 +72,7 @@ describe('app-root-param-getters - private cache', () => {
it('should allow using root params within a "use cache: private" - dev', async () => {
const browser = await next.browser('/en/us/use-cache-private')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementById('param').text()).toBe('en us')
})
} else {
......
import { isNextDev, nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('hello-world', () => {
const { next } = nextTestSetup({
......@@ -11,7 +11,7 @@ describe('hello-world', () => {
if (isNextDev) {
it('should not indicate there is an error when incidental math.random calls occur during component tree generation during dev', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
// The redbox assertion is currently unreliable in this test and so this is an additional check to ensure the CLI didn't print anything with `Math.random()` in it.
expect(next.cliOutput).not.toContain('Math.random()')
......
import * as path from 'path'
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
describe('async imports in cacheComponents', () => {
const { next, isNextStart, isNextDev } = nextTestSetup({
......@@ -62,7 +62,7 @@ describe('async imports in cacheComponents', () => {
if (isNextDev) {
await retry(async () => {
// we shouldn't get any errors from `spawnDynamicValidationInDev`
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
}
}
......
import { isNextDev, nextTestSetup } from 'e2e-utils'
import { assertNoErrorToast } from 'next-test-utils'
import { waitForNoErrorToast } from 'next-test-utils'
import { getPrerenderOutput } from './utils'
describe('Cache Components Errors', () => {
......@@ -314,7 +314,7 @@ describe('Cache Components Errors', () => {
if (isNextDev) {
it('should not show a collapsed redbox error', async () => {
const browser = await next.browser(pathname)
await assertNoErrorToast(browser)
await waitForNoErrorToast(browser)
})
} else {
it('should partially prerender when all dynamic components are inside a Suspense boundary', async () => {
......@@ -441,7 +441,7 @@ describe('Cache Components Errors', () => {
if (isNextDev) {
it('should not show a collapsed redbox error', async () => {
const browser = await next.browser(pathname)
await assertNoErrorToast(browser)
await waitForNoErrorToast(browser)
})
} else {
it('should not error the build when all routes are static', async () => {
......@@ -685,7 +685,7 @@ describe('Cache Components Errors', () => {
if (isNextDev) {
it('should not show a collapsed redbox error', async () => {
const browser = await next.browser(pathname)
await assertNoErrorToast(browser)
await waitForNoErrorToast(browser)
})
} else {
it('should partially prerender when all dynamic components are inside a Suspense boundary', async () => {
......@@ -1622,7 +1622,7 @@ describe('Cache Components Errors', () => {
if (isNextDev) {
it('does not show a validation error in the dev overlay', async () => {
const browser = await next.browser(pathname)
await assertNoErrorToast(browser)
await waitForNoErrorToast(browser)
})
} else {
it('should not error the build sync IO is used inside a Suspense Boundary in a client Component and nothing else is dynamic', async () => {
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
waitForRedbox,
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
......@@ -26,7 +26,7 @@ describe('cache-components-route-handler-errors', () => {
if (isNextDev) {
// Test the first route handler with "dynamic" config
const browser = await next.browser('/route-with-dynamic')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......
......@@ -3,7 +3,7 @@ import { nextTestSetup } from 'e2e-utils'
// Only Turbopack runs the transform on the layout once in edge and non-edge contexts
// so we only test this on Turbopack
import {
assertHasRedbox,
waitForRedbox,
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
......@@ -29,7 +29,7 @@ import {
if (isNextDev) {
const browser = await next.browser('/edge-with-layout/edge')
assertHasRedbox(browser)
waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......
import { nextTestSetup } from 'e2e-utils'
import {
retry,
assertHasRedbox,
waitForRedbox,
getRedboxDescription,
getRedboxSource,
} from 'next-test-utils'
......@@ -26,7 +26,7 @@ describe('cache-components-segment-configs', () => {
if (isNextDev) {
const browser = await next.browser('/revalidate')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......@@ -87,7 +87,7 @@ describe('cache-components-segment-configs', () => {
if (isNextDev) {
const browser = await next.browser('/revalidate')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
import { waitForNoRedbox, retry } from 'next-test-utils'
describe('cache-components', () => {
const { next, isNextDev } = nextTestSetup({
......@@ -32,7 +32,7 @@ describe('cache-components', () => {
// we expect this error not to be logged anymore.
expect(next.cliOutput).toMatch('Error: Route "/server-action-inline"')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
}
})
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getRedboxSource,
retry,
} from 'next-test-utils'
......@@ -21,7 +21,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
it('should error with swc if you have codemod comments left', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
if (process.env.IS_TURBOPACK_TEST) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
......@@ -82,7 +82,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
// Recover the original file content
await next.patchFile('app/page.tsx', originFileContent)
......@@ -91,7 +91,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
it('should disappear the error when you rre the codemod comment', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
let originFileContent
await next.patchFile('app/page.tsx', (code) => {
......@@ -103,7 +103,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
})
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
// Recover the original file content
......@@ -113,7 +113,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
it('should disappear the error when you replace with bypass comment', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
let originFileContent
await next.patchFile('app/page.tsx', (code) => {
......@@ -122,7 +122,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
})
await retry(async () => {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
})
// Recover the original file content
......
......@@ -27,7 +27,7 @@ describe('app-dir - errors', () => {
if (isNextDev) {
// TODO: investigate desired behavior here as it is currently
// minimized by default
// await assertHasRedbox(browser)
// await waitForRedbox(browser)
// expect(await getRedboxHeader(browser)).toMatch(/this is a test/)
} else {
expect(
......@@ -63,7 +63,7 @@ describe('app-dir - errors', () => {
if (isNextDev) {
// TODO-APP: ensure error overlay is shown for errors that happened before/during hydration
// await assertHasRedbox(browser)
// await waitForRedbox(browser)
// expect(await getRedboxHeader(browser)).toMatch(/this is a test/)
}
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getRedboxDescription,
} from 'next-test-utils'
......@@ -22,7 +22,7 @@ describe('app dir - forbidden with default forbidden boundary', () => {
await browser.elementByCss('#trigger-forbidden').click()
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxDescription(browser)).toMatch(
/forbidden\(\) is not allowed to use in root layout/
)
......@@ -34,7 +34,7 @@ describe('app dir - forbidden with default forbidden boundary', () => {
const browser = await next.browser('/?root-forbidden=1')
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxDescription(browser)).toBe(
'Error: forbidden() is not allowed to use in root layout'
)
......@@ -72,7 +72,7 @@ describe('app dir - forbidden with default forbidden boundary', () => {
)
await browser.loadPage(next.url + '/group-dynamic/403')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.waitForElementByCss('.group-root-layout')
expect(await browser.elementByCss('.next-error-h1').text()).toBe('403')
})
......
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox } from 'next-test-utils'
import { waitForRedbox } from 'next-test-utils'
describe('app dir - global-error - error-in-global-error', () => {
const { next, isNextDev } = nextTestSetup({
......@@ -12,7 +12,7 @@ describe('app dir - global-error - error-in-global-error', () => {
expect(text).toBe('Custom Global Error')
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
await expect(browser).toDisplayRedbox(`
{
"description": "error in page",
......@@ -37,7 +37,7 @@ describe('app dir - global-error - error-in-global-error', () => {
)
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
await expect(browser).toDisplayRedbox(`
[
{
......
import { assertHasRedbox, getRedboxHeader } from 'next-test-utils'
import { waitForRedbox, getRedboxHeader } from 'next-test-utils'
import { nextTestSetup } from 'e2e-utils'
async function testDev(browser, errorRegex) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxHeader(browser)).toMatch(errorRegex)
}
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('global-not-found - basic', () => {
const { next, isNextDev } = nextTestSetup({
......@@ -9,7 +9,7 @@ describe('global-not-found - basic', () => {
it('should render global-not-found for 404', async () => {
const browser = await next.browser('/does-not-exist')
if (isNextDev) {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
}
const errorTitle = await browser.elementByCss('#global-error-title').text()
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('global-not-found - no-root-layout', () => {
const { next, isNextDev } = nextTestSetup({
......@@ -9,7 +9,7 @@ describe('global-not-found - no-root-layout', () => {
it('should render global-not-found for 404', async () => {
const browser = await next.browser('/does-not-exist')
if (isNextDev) {
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
}
const errorTitle = await browser.elementByCss('#global-error-title').text()
......
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, getRedboxHeader } from 'next-test-utils'
import { waitForRedbox, getRedboxHeader } from 'next-test-utils'
const errorMessage =
'images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config'
async function testDev(browser, errorRegex) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxHeader(browser)).toMatch(errorRegex)
}
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('metadata-route-like-pages', () => {
const { next } = nextTestSetup({
......@@ -8,13 +8,13 @@ describe('metadata-route-like-pages', () => {
it('should able to visit sitemap page', async () => {
const browser = await next.browser('/sitemap')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('h1').text()).toBe('Sitemap')
})
it('should able to visit icon page', async () => {
const browser = await next.browser('/icon')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('h1').text()).toBe('Icon')
})
})
/* eslint-env jest */
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
waitForRedbox,
getRedboxDescription,
} from '../../../../lib/next-test-utils'
......@@ -18,7 +18,7 @@ describe('after() in generateStaticParams - thrown errors', () => {
it('shows the error overlay if an error is thrown inside after', async () => {
await next.start()
const browser = await next.browser('/callback/1')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const route = '/callback/[myParam]'
expect(await getRedboxDescription(browser)).toContain(
`My cool error thrown inside after on route "${route}"`
......
/* eslint-env jest */
import { nextTestSetup } from 'e2e-utils'
import * as Log from './utils/log'
import { assertNoRedbox, retry } from '../../../../lib/next-test-utils'
import { waitForNoRedbox, retry } from '../../../../lib/next-test-utils'
describe('after() in generateStaticParams', () => {
const { next, isNextDev, skipped } = nextTestSetup({
......@@ -31,7 +31,7 @@ describe('after() in generateStaticParams', () => {
const browser = await next.browser('/one/a')
expect(await browser.elementByCss('body').text()).toBe('Param: a')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await retry(async () => {
expect(Log.readCliLogs(getLogs())).toContainEqual({
source: '[generateStaticParams] /one/[myParam]',
......@@ -40,7 +40,7 @@ describe('after() in generateStaticParams', () => {
await browser.get(new URL('/two/d', next.url).href)
expect(await browser.elementByCss('body').text()).toBe('Param: d')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await retry(async () => {
expect(Log.readCliLogs(getLogs())).toContainEqual({
source: '[generateStaticParams] /two/[myParam]',
......
/* eslint-env jest */
import { nextTestSetup, isNextDev } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource, retry } from 'next-test-utils'
import { waitForRedbox, getRedboxSource, retry } from 'next-test-utils'
import * as Log from './utils/log'
// using after is a compile-time error in build mode.
......@@ -60,7 +60,7 @@ _describe('after() - pages', () => {
])('$title', async ({ path }) => {
const browser = await next.browser(path)
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatch(
/You're importing a component that needs "?after"?\. That only works in a Server Component which is not supported in the pages\/ directory\./
)
......
import { nextTestSetup, FileRef } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource } from 'next-test-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
import { join } from 'path'
import cheerio from 'cheerio'
......@@ -481,7 +481,7 @@ describe('app dir - next/font', () => {
'./does-not-exist.woff2'
)
)
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toInclude(
"Can't resolve './does-not-exist.woff2'"
)
......
import { nextTestSetup, FileRef } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForRedbox,
waitForNoRedbox,
getRedboxCallStack,
getRedboxSource,
} from 'next-test-utils'
......@@ -43,7 +43,7 @@ describe('non-root-project-monorepo', () => {
it('should work on client-side', async () => {
const browser = await next.browser('/monorepo-package-ssr')
expect(await browser.elementByCss('p').text()).toBe('Hello Typescript')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
expect(await browser.elementByCss('p').text()).toBe('Hello Typescript')
await browser.close()
})
......@@ -66,7 +66,7 @@ describe('non-root-project-monorepo', () => {
it('should work on client-side', async () => {
const browser = await next.browser('/import-meta-url-ssr')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
if (isTurbopack) {
// Turbopack intentionally doesn't expose the full path to the browser bundles
expect(await browser.elementByCss('p').text()).toBe(
......@@ -85,7 +85,7 @@ describe('non-root-project-monorepo', () => {
describe('source-maps', () => {
it('should work on RSC', async () => {
const browser = await next.browser('/source-maps-rsc')
await assertHasRedbox(browser)
await waitForRedbox(browser)
if (isTurbopack) {
// TODO the function name should be hidden
......@@ -148,7 +148,7 @@ describe('non-root-project-monorepo', () => {
it('should work on SSR', async () => {
const browser = await next.browser('/source-maps-ssr')
await assertHasRedbox(browser)
await waitForRedbox(browser)
if (isTurbopack) {
// TODO the function name should be hidden
......@@ -211,7 +211,7 @@ describe('non-root-project-monorepo', () => {
it('should work on client-side', async () => {
const browser = await next.browser('/source-maps-client')
await assertHasRedbox(browser)
await waitForRedbox(browser)
if (isTurbopack) {
// TODO the function name should be hidden
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('app dir - not found with default 404 page', () => {
const { next, isNextDev, skipped } = nextTestSetup({
......@@ -92,7 +92,7 @@ describe('app dir - not found with default 404 page', () => {
)
await browser.loadPage(next.url + '/group-dynamic/404')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
await browser.waitForElementByCss('.group-root-layout')
expect(await browser.elementByCss('.next-error-h1').text()).toBe('404')
})
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('app dir - not found with nested layouts and custom not-found', () => {
const { next, skipped } = nextTestSetup({
......@@ -13,7 +13,7 @@ describe('app dir - not found with nested layouts and custom not-found', () => {
it('should render the custom not-found page when notFound() is thrown from a page within the group', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
const heading = await browser.elementByCss('h1#not-found-heading')
expect(await heading.text()).toBe('Group Not Found Page')
})
......
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox } from 'next-test-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('app dir - not found with nested layouts', () => {
const { next, skipped } = nextTestSetup({
......@@ -13,7 +13,7 @@ describe('app dir - not found with nested layouts', () => {
it('should render the custom not-found page when notFound() is thrown from a page', async () => {
const browser = await next.browser('/')
await assertNoRedbox(browser)
await waitForNoRedbox(browser)
const heading = await browser.elementByCss('h1#not-found-heading')
expect(await heading.text()).toBe('Custom Not Found Page')
})
......
import path from 'path'
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, retry } from 'next-test-utils'
import { waitForRedbox, retry } from 'next-test-utils'
describe('parallel-routes-leaf-segments-build-error', () => {
const { next, isNextDev, skipped } = nextTestSetup({
......@@ -30,7 +30,7 @@ describe('parallel-routes-leaf-segments-build-error', () => {
it('should throw MissingDefaultParallelRouteError for @header slot', async () => {
if (isNextDev) {
const browser = await next.browser('/with-children/child')
await assertHasRedbox(browser)
await waitForRedbox(browser)
await retry(async () => {
const logs = await browser.log()
......@@ -56,7 +56,7 @@ describe('parallel-routes-leaf-segments-build-error', () => {
it('should throw MissingDefaultParallelRouteError for parallel slots', async () => {
if (isNextDev) {
const browser = await next.browser('/with-groups-and-children/nested')
await assertHasRedbox(browser)
await waitForRedbox(browser)
await retry(async () => {
const logs = await browser.log()
......
import { nextTestSetup } from 'e2e-utils'
import { retry, assertHasRedbox, getRedboxDescription } from 'next-test-utils'
import { retry, waitForRedbox, getRedboxDescription } from 'next-test-utils'
describe('app-dir refresh', () => {
const { next, skipped, isNextDev } = nextTestSetup({
......@@ -38,7 +38,7 @@ describe('app-dir refresh', () => {
const browser = await next.browser('/refresh-invalid-render')
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
const description = await getRedboxDescription(browser)
expect(description).toContain(
'refresh can only be called from within a Server Action'
......@@ -67,7 +67,7 @@ describe('app-dir refresh', () => {
const browser = await next.browser('/refresh-invalid-cache')
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
const description = await getRedboxDescription(browser)
expect(description).toContain(
'refresh can only be called from within a Server Action'
......
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, getRedboxHeader, retry } from 'next-test-utils'
import { waitForRedbox, getRedboxHeader, retry } from 'next-test-utils'
describe('revalidateTag-rsc', () => {
const { next, isNextDev, isNextDeploy } = nextTestSetup({
......@@ -28,7 +28,7 @@ describe('revalidateTag-rsc', () => {
await browser.elementByCss('#revalidate-via-page').click()
if (isNextDev) {
await assertHasRedbox(browser)
await waitForRedbox(browser)
await expect(getRedboxHeader(browser)).resolves.toContain(
'Route /revalidate_via_page used "revalidateTag data"'
)
......
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, check, getRedboxSource } from 'next-test-utils'
import { waitForRedbox, check, getRedboxSource } from 'next-test-utils'
describe('app-dir root layout', () => {
const {
......@@ -23,7 +23,7 @@ describe('app-dir root layout', () => {
waitHydration: false,
})
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"Please make sure to include the following tags in your root layout: <html>, <body>.
......@@ -37,7 +37,7 @@ describe('app-dir root layout', () => {
})
await browser.elementByCss('a').click()
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"Please make sure to include the following tags in your root layout: <html>, <body>.
......@@ -50,7 +50,7 @@ describe('app-dir root layout', () => {
waitHydration: false,
})
await assertHasRedbox(browser)
await waitForRedbox(browser)
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"Please make sure to include the following tags in your root layout: <html>, <body>.
......
/* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource } from 'next-test-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('Invalid Global CSS with Custom App', () => {
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({
......@@ -33,7 +33,7 @@ describe('Invalid Global CSS with Custom App', () => {
it('should show a build error', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const errorSource = await getRedboxSource(browser)
if (isTurbopack) {
......
/* eslint-env jest */
import { isNextStart, nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, getRedboxSource } from 'next-test-utils'
import { waitForRedbox, getRedboxSource } from 'next-test-utils'
describe('Invalid Global CSS', () => {
const { next, skipped, isTurbopack, isRspack } = nextTestSetup({
......@@ -33,7 +33,7 @@ describe('Invalid Global CSS', () => {
it('should show a build error', async () => {
const browser = await next.browser('/')
await assertHasRedbox(browser)
await waitForRedbox(browser)
const errorSource = await getRedboxSource(browser)
if (isTurbopack) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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