rsnext/test/e2e/app-dir/not-found/not-found.test.ts
Shu Ding 54fce53dd9
Make sure the global not found route doesn't conflict with existing /not-found route (#47619)
In #47328 we made the root level `/not-found.js` a special entry, to
override the page 404 during builds. However, it's possible that the
user has a valid `/not-found/page.js` route that might conflict with
this special entry. This PR changes the entry to be `/_not-found` so it
will never conflict with existing valid entries.
2023-03-28 21:54:58 +02:00

32 lines
1 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'app dir - not-found',
{
files: __dirname,
skipDeployment: true,
},
({ next, isNextDev }) => {
describe('root not-found page', () => {
it('should use the not-found page for non-matching routes', async () => {
const html = await next.render('/random-content')
expect(html).toContain('This Is The Not Found Page')
})
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")
})
if (!isNextDev) {
it('should create the 404 mapping and copy the file to pages', async () => {
const html = await next.readFile('.next/server/pages/404.html')
expect(html).toContain('This Is The Not Found Page')
expect(
await next.readFile('.next/server/pages-manifest.json')
).toContain('"pages/404.html"')
})
}
})
}
)