File size: 1,176 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

describe('empty-generate-static-params', () => {
  const { next, skipped } = nextTestSetup({
    files: __dirname,
    skipDeployment: true,
  })

  if (skipped) return

  it('should mark the page with empty generateStaticParams as SSG in build output', async () => {
    const isPPREnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
    expect(next.cliOutput).toContain(`${isPPREnabled ? '◐' : '●'} /[slug]`)
  })

  it('should be a cache miss on the initial render followed by a HIT after being generated', async () => {
    const firstResponse = await next.fetch('/foo')
    expect(firstResponse.status).toBe(200)

    // With PPR enabled, the initial request doesn't send back a cache header
    const isPPREnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'

    expect(firstResponse.headers.get('x-nextjs-cache')).toBe(
      isPPREnabled ? null : 'MISS'
    )

    retry(async () => {
      const secondResponse = await next.fetch('/foo')
      expect(secondResponse.status).toBe(200)
      expect(secondResponse.headers.get('x-nextjs-cache')).toBe('HIT')
    })
  })
})