Skip to content

Commit

Permalink
Print Redbox content if assertNoRedbox fails
Browse files Browse the repository at this point in the history
Just saying there is a Redbox doesn't help understand why it failed.
Now we display header, description and source to help understand the failure.
  • Loading branch information
eps1lon committed Jul 19, 2024
1 parent eeff555 commit 622a66d
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 622a66d

Please sign in to comment.