(mode)
| 19 | let app |
| 20 | |
| 21 | const runTests = (mode) => { |
| 22 | const isDev = mode === 'dev' |
| 23 | |
| 24 | it('should respond to 404 correctly', async () => { |
| 25 | const res = await fetchViaHTTP(appPort, '/404') |
| 26 | expect(res.status).toBe(404) |
| 27 | expect(await res.text()).toContain('This page could not be found') |
| 28 | }) |
| 29 | |
| 30 | it('should render error correctly', async () => { |
| 31 | const text = await renderViaHTTP(appPort, '/err') |
| 32 | expect(text).toContain(isDev ? 'oops' : 'Internal Server Error') |
| 33 | }) |
| 34 | |
| 35 | it('should render index page normal', async () => { |
| 36 | const html = await renderViaHTTP(appPort, '/') |
| 37 | expect(html).toContain('hello from index') |
| 38 | }) |
| 39 | |
| 40 | if (!isDev) { |
| 41 | it('should set pages404 in routes-manifest correctly', async () => { |
| 42 | const data = await fs.readJSON(join(appDir, '.next/routes-manifest.json')) |
| 43 | expect(data.pages404).toBe(true) |
| 44 | }) |
| 45 | |
| 46 | it('should have output 404.html', async () => { |
| 47 | const page = getPageFileFromPagesManifest(appDir, '/404') |
| 48 | expect(page.endsWith('.html')).toBe(true) |
| 49 | }) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | describe('Default 404 Page with custom _error', () => { |
| 54 | ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( |
no test coverage detected