(mode = 'server')
| 28 | let app |
| 29 | |
| 30 | const runTests = (mode = 'server') => { |
| 31 | it('should use pages/500', async () => { |
| 32 | const html = await renderViaHTTP(appPort, '/500') |
| 33 | expect(html).toContain('custom 500 page') |
| 34 | }) |
| 35 | |
| 36 | it('should set correct status code with pages/500', async () => { |
| 37 | const res = await fetchViaHTTP(appPort, '/500') |
| 38 | expect(res.status).toBe(500) |
| 39 | }) |
| 40 | |
| 41 | it('should not error when visited directly', async () => { |
| 42 | const res = await fetchViaHTTP(appPort, '/500') |
| 43 | expect(res.status).toBe(500) |
| 44 | expect(await res.text()).toContain('custom 500 page') |
| 45 | }) |
| 46 | |
| 47 | if (mode !== 'dev') { |
| 48 | it('should output 500.html during build', async () => { |
| 49 | const page = getPageFileFromPagesManifest(appDir, '/500') |
| 50 | expect(page.endsWith('.html')).toBe(true) |
| 51 | }) |
| 52 | |
| 53 | it('should add /500 to pages-manifest correctly', async () => { |
| 54 | const manifest = await fs.readJSON( |
| 55 | join(appDir, '.next', mode, 'pages-manifest.json') |
| 56 | ) |
| 57 | expect('/500' in manifest).toBe(true) |
| 58 | }) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | describe('500 Page Support', () => { |
| 63 | ;(process.env.TURBOPACK_BUILD ? describe.skip : describe)( |
no test coverage detected