mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
These tests won't ever be run in a deployed environment, so this removes `skipDeployment` so it's easier to grok which tests are intentionally disabled because they don't work when deployed.
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('empty-generate-static-params', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
skipStart: true,
|
|
})
|
|
|
|
if (skipped) return
|
|
|
|
// If we're not using cache components, there shouldn't be any build errors!
|
|
if (process.env.__NEXT_CACHE_COMPONENTS !== 'true') {
|
|
beforeAll(async () => {
|
|
await next.start()
|
|
})
|
|
|
|
it('should mark the page with empty generateStaticParams as SSG in build output', async () => {
|
|
const isPPREnabled = process.env.__NEXT_CACHE_COMPONENTS === '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_CACHE_COMPONENTS === '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')
|
|
})
|
|
})
|
|
} else {
|
|
it('should throw an error when generateStaticParams returns an empty array', async () => {
|
|
await expect(() => next.start()).rejects.toThrow()
|
|
|
|
expect(next.cliOutput).toContain(
|
|
'https://nextjs.org/docs/messages/empty-generate-static-params'
|
|
)
|
|
})
|
|
}
|
|
})
|