Skip to content

Commit 622a66d

Browse files
committed
Print Redbox content if assertNoRedbox fails
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.
1 parent eeff555 commit 622a66d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/lib/next-test-utils.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,18 @@ export async function assertNoRedbox(browser: BrowserInterface) {
854854
})
855855

856856
if (hasRedbox) {
857-
const error = new Error('Expected no Redbox but found one')
857+
const [redboxHeader, redboxDescription, redboxSource] = await Promise.all([
858+
getRedboxHeader(browser).catch(() => '<missing>'),
859+
getRedboxDescription(browser).catch(() => '<missing>'),
860+
getRedboxSource(browser).catch(() => '<missing>'),
861+
])
862+
863+
const error = new Error(
864+
'Expected no Redbox but found one\n' +
865+
`header: ${redboxHeader}\n` +
866+
`description: ${redboxDescription}\n` +
867+
`source: ${redboxSource}`
868+
)
858869
Error.captureStackTrace(error, assertHasRedbox)
859870
throw error
860871
}

0 commit comments

Comments
 (0)