Skip to content

Commit

Permalink
Print Redbox content if assertNoRedbox fails (#67973)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jul 19, 2024
1 parent bfbd971 commit c175c24
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/lib/next-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,18 @@ export async function assertNoRedbox(browser: BrowserInterface) {
})

if (hasRedbox) {
const error = new Error('Expected no Redbox but found one')
const [redboxHeader, redboxDescription, redboxSource] = await Promise.all([
getRedboxHeader(browser).catch(() => '<missing>'),
getRedboxDescription(browser).catch(() => '<missing>'),
getRedboxSource(browser).catch(() => '<missing>'),
])

const error = new Error(
'Expected no Redbox but found one\n' +
`header: ${redboxHeader}\n` +
`description: ${redboxDescription}\n` +
`source: ${redboxSource}`
)
Error.captureStackTrace(error, assertHasRedbox)
throw error
}
Expand Down

0 comments on commit c175c24

Please sign in to comment.