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

Function runTests

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

Source from the content-addressed store, hash-verified

19let buildId
20
21function runTests(route, routePath) {
22 it(`[${route}] should regenerate page when revalidate time exceeded`, async () => {
23 const fileName = join(
24 appDir,
25 '.next',
26 'server',
27 getPageFileFromPagesManifest(appDir, routePath).replace('.js', '.html')
28 )
29 const initialHtmlFile = await fs.readFile(fileName, 'utf8')
30
31 await waitFor(1000) // Wait revalidate duration
32
33 expect(await renderViaHTTP(appPort, route)).toBe(initialHtmlFile)
34
35 await waitFor(500) // Wait for regeneration to occur
36
37 const regeneratedFileHtml = await fs.readFile(fileName, 'utf8')
38 expect(regeneratedFileHtml).not.toBe(initialHtmlFile)
39 expect(await renderViaHTTP(appPort, route)).toBe(regeneratedFileHtml)
40 })
41
42 it(`[${route}] should regenerate /_next/data when revalidate time exceeded`, async () => {
43 const fileName = join(
44 appDir,
45 '.next',
46 'server',
47 getPageFileFromPagesManifest(appDir, routePath).replace('.js', '.json')
48 )
49 const route = join(`/_next/data/${buildId}`, `${routePath}.json`)
50 const initialFileJson = await fs.readFile(fileName, 'utf8')
51
52 await waitFor(1000) // Wait revalidate duration
53
54 expect(JSON.parse(await renderViaHTTP(appPort, route))).toEqual(
55 JSON.parse(initialFileJson)
56 )
57
58 await waitFor(500) // Wait for regeneration to occur
59
60 const regeneratedFileJson = await fs.readFile(fileName, 'utf8')
61 expect(regeneratedFileJson).not.toBe(initialFileJson)
62 expect(JSON.parse(await renderViaHTTP(appPort, route))).toEqual(
63 JSON.parse(regeneratedFileJson)
64 )
65 })
66}
67
68describe('SSG Prerender Revalidate', () => {
69 ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(

Callers 1

index.test.tsFile · 0.70

Calls 9

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

Tested by

no test coverage detected