mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Redesign the https://github.com/vercel/next.js/pull/87988 error pages to be more aligned with Next.js aesthetic, along with copy to be sharper. | Client | Server | |--------|--------| | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 26 07@2x" src="https://github.com/user-attachments/assets/f42bee3e-2ce8-44dc-9e26-79b81cf965d8" /> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 23 38@2x" src="https://github.com/user-attachments/assets/19a596c6-6da7-4a42-9b53-16e3c2e6f867" /> | | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 25 22@2x" src="https://github.com/user-attachments/assets/a3075d79-c76a-4fbf-af6e-d4a44f1434eb" /> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 24 17@2x" src="https://github.com/user-attachments/assets/5811cc98-f8e4-4451-bf9c-501548292245" /> | --------- Co-authored-by: Jimmy Lai <[email protected]> Co-authored-by: Tim Neutkens <[email protected]>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import fsp from 'fs/promises'
|
|
import path from 'path'
|
|
|
|
describe('500-page app-router-only', () => {
|
|
const { next, isNextStart, isNextDeploy } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
if (isNextDeploy) {
|
|
it('should render app router 500 page when route error', async () => {
|
|
const $ = await next.render$('/route-error')
|
|
expect($('html').attr('id')).toBe('__next_error__')
|
|
// Server errors show "This page couldn\u2019t load"
|
|
expect($('body').text()).toContain('This page couldn\u2019t load')
|
|
})
|
|
}
|
|
|
|
if (isNextStart) {
|
|
it('should use app router to generate 500.html when no pages _error.tsx exists', async () => {
|
|
const html = await fsp.readFile(
|
|
path.join(next.testDir, '.next', 'server', 'pages', '500.html'),
|
|
'utf8'
|
|
)
|
|
// Not use pages router to generate 500.html
|
|
expect(html).toContain('__next_error__')
|
|
// Server errors show "This page couldn\u2019t load"
|
|
expect(html).toContain('This page couldn\u2019t load')
|
|
// global-error is not used in app router 500.html
|
|
expect(html).not.toContain('app-router-global-error')
|
|
})
|
|
|
|
it('pages manifest should only contain 404 and 500', async () => {
|
|
const pagesManifest = await fsp.readFile(
|
|
path.join(next.testDir, '.next', 'server', 'pages-manifest.json'),
|
|
'utf8'
|
|
)
|
|
const pagesManifestJson = JSON.parse(pagesManifest)
|
|
expect(pagesManifestJson).toMatchInlineSnapshot(`
|
|
{
|
|
"/404": "pages/404.html",
|
|
"/500": "pages/500.html",
|
|
}
|
|
`)
|
|
})
|
|
|
|
it('should not contain pages router routes default assets', async () => {
|
|
// do not contain _app, _document, _error routes folder or files in .next/server/pages
|
|
const pagesDir = path.join(next.testDir, '.next', 'server', 'pages')
|
|
const files = await fsp.readdir(pagesDir)
|
|
expect(files).not.toContain('500')
|
|
expect(files).not.toContain('_app')
|
|
expect(files).not.toContain('_document')
|
|
expect(files).not.toContain('_error')
|
|
})
|
|
}
|
|
})
|