MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/404-page-custom-error/test/index.test.ts:21–51  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

19let app
20
21const 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
53describe('Default 404 Page with custom _error', () => {
54 ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(

Callers 1

index.test.tsFile · 0.70

Calls 9

fetchViaHTTPFunction · 0.90
renderViaHTTPFunction · 0.90
joinFunction · 0.90
readJSONMethod · 0.80
textMethod · 0.65
itFunction · 0.50
expectFunction · 0.50
endsWithMethod · 0.45

Tested by

no test coverage detected