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

[test] Use new Redbox matchers in app/ undefined-default-export (#76781)

Missing stack tracked in https://linear.app/vercel/issue/NDX-920/
parent 92b18a95
...@@ -16,11 +16,18 @@ describe('Undefined default export', () => { ...@@ -16,11 +16,18 @@ describe('Undefined default export', () => {
]), ]),
'/specific-path/server' '/specific-path/server'
) )
const { session } = sandbox const { browser } = sandbox
await session.assertHasRedbox()
expect(await session.getRedboxDescription()).toInclude( await expect(browser).toDisplayRedbox(`
'The default export is not a React Component in "/specific-path/server/page"' {
) "count": 1,
"description": "Error: The default export is not a React Component in "/specific-path/server/page"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`)
}) })
it('should error if layout component does not have default export', async () => { it('should error if layout component does not have default export', async () => {
...@@ -35,11 +42,18 @@ describe('Undefined default export', () => { ...@@ -35,11 +42,18 @@ describe('Undefined default export', () => {
]), ]),
'/specific-path/server' '/specific-path/server'
) )
const { session } = sandbox const { browser } = sandbox
await session.assertHasRedbox()
expect(await session.getRedboxDescription()).toInclude( await expect(browser).toDisplayRedbox(`
'The default export is not a React Component in "/specific-path/server/layout"' {
) "count": 1,
"description": "Error: The default export is not a React Component in "/specific-path/server/layout"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`)
}) })
it('should error if not-found component does not have default export when trigger not-found boundary', async () => { it('should error if not-found component does not have default export when trigger not-found boundary', async () => {
...@@ -57,16 +71,23 @@ describe('Undefined default export', () => { ...@@ -57,16 +71,23 @@ describe('Undefined default export', () => {
]), ]),
'/will-not-found' '/will-not-found'
) )
const { session } = sandbox const { browser } = sandbox
await session.assertHasRedbox()
expect(await session.getRedboxDescription()).toInclude( await expect(browser).toDisplayRedbox(`
'The default export is not a React Component in "/will-not-found/not-found"' {
) "count": 1,
"description": "Error: The default export is not a React Component in "/will-not-found/not-found"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`)
}) })
it('should error when page component export is not valid', async () => { it('should error when page component export is not valid', async () => {
await using sandbox = await createSandbox(next, undefined, '/') await using sandbox = await createSandbox(next, undefined, '/')
const { session, browser } = sandbox const { browser } = sandbox
await next.patchFile('app/page.js', 'const a = 123') await next.patchFile('app/page.js', 'const a = 123')
...@@ -74,10 +95,16 @@ describe('Undefined default export', () => { ...@@ -74,10 +95,16 @@ describe('Undefined default export', () => {
// Wait for the DOM node #__next to be present // Wait for the DOM node #__next to be present
await browser.waitForElementByCss('#__next') await browser.waitForElementByCss('#__next')
await session.assertHasRedbox() await expect(browser).toDisplayRedbox(`
expect(await session.getRedboxDescription()).toInclude( {
'The default export is not a React Component in "/page"' "count": 1,
) "description": "Error: The default export is not a React Component in "/page"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`)
}) })
it('should error when page component export is not valid on initial load', async () => { it('should error when page component export is not valid on initial load', async () => {
...@@ -91,10 +118,17 @@ describe('Undefined default export', () => { ...@@ -91,10 +118,17 @@ describe('Undefined default export', () => {
]), ]),
'/server-with-errors/page-export-initial-error' '/server-with-errors/page-export-initial-error'
) )
const { session } = sandbox const { browser } = sandbox
await session.assertHasRedbox()
expect(await session.getRedboxDescription()).toInclude( await expect(browser).toDisplayRedbox(`
'The default export is not a React Component in "/server-with-errors/page-export-initial-error/page"' {
) "count": 1,
"description": "Error: The default export is not a React Component in "/server-with-errors/page-export-initial-error/page"",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
}
`)
}) })
}) })
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