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

Function runTests

test/integration/prerender-no-revalidate/test/index.test.ts:21–76  ·  view source on GitHub ↗
(route, routePath)

Source from the content-addressed store, hash-verified

19let stderr
20
21function runTests(route, routePath) {
22 it(`[${route}] should not revalidate when set to false`, async () => {
23 const fileName = join(
24 appDir,
25 '.next',
26 'server',
27 getPageFileFromPagesManifest(appDir, routePath)
28 )
29 const initialHtml = await renderViaHTTP(appPort, route)
30 const initialFileHtml = await fs.readFile(fileName, 'utf8')
31
32 let newHtml = await renderViaHTTP(appPort, route)
33 expect(initialHtml).toBe(newHtml)
34 expect(await fs.readFile(fileName, 'utf8')).toBe(initialFileHtml)
35
36 await waitFor(500)
37
38 newHtml = await renderViaHTTP(appPort, route)
39 expect(initialHtml).toBe(newHtml)
40 expect(await fs.readFile(fileName, 'utf8')).toBe(initialFileHtml)
41
42 await waitFor(500)
43
44 newHtml = await renderViaHTTP(appPort, route)
45 expect(initialHtml).toBe(newHtml)
46 expect(await fs.readFile(fileName, 'utf8')).toBe(initialFileHtml)
47
48 expect(stderr).not.toContain('GSP was re-run')
49 })
50
51 it(`[${route}] should not revalidate /_next/data when set to false`, async () => {
52 const fileName = join(
53 appDir,
54 '.next',
55 'server',
56 getPageFileFromPagesManifest(appDir, routePath)
57 )
58 const route = join(`/_next/data/${buildId}`, `${routePath}.json`)
59
60 const initialData = JSON.parse(await renderViaHTTP(appPort, route))
61 const initialFileJson = await fs.readFile(fileName, 'utf8')
62
63 expect(JSON.parse(await renderViaHTTP(appPort, route))).toEqual(initialData)
64 expect(await fs.readFile(fileName, 'utf8')).toBe(initialFileJson)
65 await waitFor(500)
66
67 expect(JSON.parse(await renderViaHTTP(appPort, route))).toEqual(initialData)
68 expect(await fs.readFile(fileName, 'utf8')).toBe(initialFileJson)
69 await waitFor(500)
70
71 expect(JSON.parse(await renderViaHTTP(appPort, route))).toEqual(initialData)
72 expect(await fs.readFile(fileName, 'utf8')).toBe(initialFileJson)
73
74 expect(stderr).not.toContain('GSP was re-run')
75 })
76}
77
78describe('SSG Prerender No Revalidate', () => {

Callers 1

index.test.tsFile · 0.70

Calls 8

joinFunction · 0.90
renderViaHTTPFunction · 0.90
waitForFunction · 0.90
itFunction · 0.50
expectFunction · 0.50
readFileMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected