(route, routePath)
| 19 | let stderr |
| 20 | |
| 21 | function 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 | |
| 78 | describe('SSG Prerender No Revalidate', () => { |
no test coverage detected