mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Edge runtime doesn't have `/404` entry points as not-found, if server hits 404 it's hitting `/_not-found` entry point of edge bundles unlike nodejs server rendering. In app-render it needs the information that when `pathname` (or can call `pagePath`) is `/404` it can render the `not-found.js` components properly Separate the not-found test suite into 2 parts, a basic case testing all urls with `not-found.js` boundary, and another conflict route case with `not-found.js` with `not-found/` route at the same time Fixes #53652 Fixes #53210
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
createNextDescribe(
|
|
'app dir - not-found - conflict route',
|
|
{
|
|
files: __dirname,
|
|
skipDeployment: true,
|
|
},
|
|
({ next }) => {
|
|
const runTests = () => {
|
|
it('should use the not-found page for non-matching routes', async () => {
|
|
const browser = await next.browser('/random-content')
|
|
expect(await browser.elementByCss('h1').text()).toContain(
|
|
'This Is The Not Found Page'
|
|
)
|
|
// should contain root layout content
|
|
expect(await browser.elementByCss('#layout-nav').text()).toBe('Navbar')
|
|
})
|
|
|
|
it('should allow to have a valid /not-found route', async () => {
|
|
const html = await next.render('/not-found')
|
|
expect(html).toContain("I'm still a valid page")
|
|
})
|
|
}
|
|
|
|
describe('with default runtime', () => {
|
|
runTests()
|
|
})
|
|
|
|
describe('with runtime = edge', () => {
|
|
let originalLayout = ''
|
|
|
|
beforeAll(async () => {
|
|
await next.stop()
|
|
originalLayout = await next.readFile('app/layout.js')
|
|
await next.patchFile(
|
|
'app/layout.js',
|
|
`export const runtime = 'edge'\n${originalLayout}`
|
|
)
|
|
await next.start()
|
|
})
|
|
afterAll(async () => {
|
|
await next.patchFile('app/layout.js', originalLayout)
|
|
})
|
|
|
|
runTests()
|
|
})
|
|
}
|
|
)
|