Files
Josh Story 1f60b5f193 test: restore deployment exclusion for shared Cache Components tests (#98464)
## Summary

Restore `skipDeployment` and the early return in the shared Cache
Components error-test runner. The migration in #98154 replaced them with
a force-gate pragma, but the gate transformer only processes `.test.*`
files, so the pragma in `shared.util.ts` did not preserve the deployment
exclusion.

This is a temporary rollback to unblock deploy testing. Moving the test
definitions out of the helper and migrating them again will be evaluated
separately; this PR does not change the transformer or refactor the
tests.

## Verification

- Ran all 12 importing test files through Jest in deploy mode with
deployment setup mocked to throw before any fixture or deployment work.
Before the rollback, all 12 reached that guard and failed. After the
rollback, all 12 take the legacy exclusion path and no deployment setup
is attempted.
- `pnpm typescript --skipLibCheck` passes.
- Full type-check reports the existing nine Octokit dependency
declaration errors; no errors in the changed file.

<!-- NEXT_JS_LLM -->
2026-09-09 23:15:45 +00:00

103 lines
3.0 KiB
TypeScript

import { isNextDev, nextTestSetup } from 'e2e-utils'
import type { NextInstance } from 'e2e-utils'
export interface CacheComponentsErrorsContext {
next: NextInstance
isTurbopack: boolean
isRspack: boolean
isNextStart: boolean
isDebugPrerender: boolean
prerender: (pathname: string) => Promise<void>
}
// This suite is far too slow to run as a single CI test file, so it's split
// into one `*.test.ts` entry file per group of sections (each with a
// `.partial-prefetching` variant), all sharing this wrapper. Each entry
// boots its own server (and, in `next start` mode, runs its own builds).
// Snapshots can be updated with the sibling update-snapshots.sh script.
export function runCacheComponentsErrorsTests(
registerTests: (ctx: CacheComponentsErrorsContext) => void
) {
describe('Cache Components Errors', () => {
const { next, isTurbopack, isNextStart, isRspack, skipped } = nextTestSetup(
{
files: __dirname + '/fixtures/default',
skipStart: !isNextDev,
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// No deploy-specific incompatibility is documented.
skipDeployment: true,
}
)
if (skipped) return
afterEach(async () => {
if (isNextStart) {
await next.stop()
}
})
const testCases: { isDebugPrerender: boolean; name: string }[] = []
if (isNextDev) {
testCases.push({ isDebugPrerender: false, name: 'Dev' })
} else {
const prerenderMode = process.env.NEXT_TEST_DEBUG_PRERENDER
// The snapshots can't be created for both modes at the same time because of
// an issue in the typescript plugin for prettier. Defining
// NEXT_TEST_DEBUG_PRERENDER allows us to run them sequentially, when we
// need to update the snapshots.
if (!prerenderMode || prerenderMode === 'true') {
testCases.push({
isDebugPrerender: true,
name: 'Build With --prerender-debug',
})
}
if (!prerenderMode || prerenderMode === 'false') {
testCases.push({
isDebugPrerender: false,
name: 'Build Without --prerender-debug',
})
}
}
describe.each(testCases)('$name', ({ isDebugPrerender }) => {
beforeAll(async () => {
if (isNextStart) {
const args = ['--experimental-build-mode', 'compile']
if (isDebugPrerender) {
args.push('--debug-prerender')
}
await next.build({ args })
}
})
const prerender = async (pathname: string) => {
const args = [
'--experimental-build-mode',
'generate',
'--debug-build-paths',
`app${pathname}/page.tsx`,
]
if (isDebugPrerender) {
args.push('--debug-prerender')
}
await next.build({ args })
}
registerTests({
next,
isTurbopack,
isRspack,
isNextStart,
isDebugPrerender,
prerender,
})
})
})
}