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

Function runTests

test/integration/root-optional-revalidate/test/index.test.ts:24–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24const runTests = () => {
25 it('should render / correctly', async () => {
26 const props = await getProps('/')
27 expect(props.params).toEqual({})
28
29 let cliOutput = ''
30 app.stdout.on('data', (chunk) => (cliOutput += chunk.toString()))
31 await waitFor(1000)
32 await getProps('/')
33 expect(cliOutput).toEqual('getStaticProps({ revalidateReason: "stale" })\n')
34
35 // Rendering takes time before the new cache entry is filled
36 await retry(async () => {
37 const newProps = await getProps('/')
38 expect(newProps.params).toEqual({})
39 expect(props.random).not.toBe(newProps.random)
40 })
41 })
42
43 it('should render /a correctly', async () => {
44 const props = await getProps('/a')
45 expect(props.params).toEqual({ slug: ['a'] })
46
47 let cliOutput = ''
48 app.stdout.on('data', (chunk) => (cliOutput += chunk.toString()))
49 await waitFor(1000)
50 await getProps('/a')
51 expect(cliOutput).toEqual('getStaticProps({ revalidateReason: "stale" })\n')
52
53 // Rendering takes time before the new cache entry is filled
54 await retry(async () => {
55 const newProps = await getProps('/a')
56 expect(newProps.params).toEqual({ slug: ['a'] })
57 expect(props.random).not.toBe(newProps.random)
58 })
59 })
60
61 it('should render /hello/world correctly', async () => {
62 const props = await getProps('/hello/world')
63 expect(props.params).toEqual({ slug: ['hello', 'world'] })
64
65 let cliOutput = ''
66 app.stdout.on('data', (chunk) => (cliOutput += chunk.toString()))
67 await waitFor(1000)
68 await getProps('/hello/world')
69 expect(cliOutput).toEqual('getStaticProps({ revalidateReason: "stale" })\n')
70
71 // Rendering takes time before the new cache entry is filled
72 await retry(async () => {
73 const newProps = await getProps('/hello/world')
74 expect(newProps.params).toEqual({ slug: ['hello', 'world'] })
75 expect(props.random).not.toBe(newProps.random)
76 })
77 })
78}
79
80describe('Root Optional Catch-all Revalidate', () => {
81 ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(

Callers 1

index.test.tsFile · 0.70

Calls 7

waitForFunction · 0.90
retryFunction · 0.90
getPropsFunction · 0.85
itFunction · 0.50
expectFunction · 0.50
onMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected