mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
e0966df114
## Summary - migrate Cache Components, PPR, prefetching, prerendering, revalidation, and SSG deployment exclusions to `@force-gate` - remove the corresponding `skipDeployment` options and `skipped` control flow while preserving each suite's rationale This keeps caching-related exclusions together so their deployed semantics can be reviewed by the same owners. ## Verification - verified on the combined top-of-stack tree with `pnpm typescript` - compared ordinary-mode collection before and after: all 4,670 existing test names matched - collected all 510 affected files in deploy mode: 4,578 skipped tests, zero failures <!-- NEXT_JS_LLM -->
83 lines
2.6 KiB
TypeScript
83 lines
2.6 KiB
TypeScript
import { isNextDev, nextTestSetup } from 'e2e-utils'
|
|
import { getPrerenderOutput } from './utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
|
|
// It likely asserts local CLI or runtime output that deploy tests do not expose.
|
|
// @force-gate !deploy
|
|
describe('Cache Components Errors', () => {
|
|
const { next, isTurbopack, isNextStart } = nextTestSetup({
|
|
files: __dirname + '/fixtures/console-patch',
|
|
skipStart: !isNextDev,
|
|
env: {
|
|
NODE_OPTIONS: '--require ./patch-console.js',
|
|
},
|
|
})
|
|
|
|
let cliOutputLength: number
|
|
|
|
beforeEach(async () => {
|
|
cliOutputLength = next.cliOutput.length
|
|
})
|
|
|
|
afterEach(async () => {
|
|
if (isNextStart) {
|
|
await next.stop()
|
|
}
|
|
})
|
|
|
|
describe('Sync IO in console methods', () => {
|
|
describe('Console Patching', () => {
|
|
if (isNextDev) {
|
|
it('does not warn about sync IO if console.log is patched to call new Date() internally', async () => {
|
|
await next.fetch('/404')
|
|
|
|
// Wait for after 404 is rendered to the console.
|
|
await retry(async () => {
|
|
expect(next.cliOutput).toContain('GET /404 404')
|
|
})
|
|
|
|
const from = next.cliOutput.length
|
|
|
|
await next.browser('/')
|
|
|
|
// trim off any logs after the HTTP request finished
|
|
const output = next.cliOutput.slice(from)
|
|
expect(output).toContain('GET / 200')
|
|
const snapshot = output.slice(0, output.indexOf('GET / 200')).trim()
|
|
|
|
expect(snapshot).toMatchInlineSnapshot(
|
|
`"[<timestamp>] This is a console log from a server component page"`
|
|
)
|
|
})
|
|
} else {
|
|
it('does not fail the build for Sync IO if console.log is patched to call new Date() internally', async () => {
|
|
try {
|
|
await next.build()
|
|
} catch {}
|
|
|
|
const output = getPrerenderOutput(
|
|
next.cliOutput.slice(cliOutputLength),
|
|
{ isMinified: true }
|
|
)
|
|
|
|
if (isTurbopack) {
|
|
expect(output).toMatchInlineSnapshot(`
|
|
"[<timestamp>] This is a console log from a server component page
|
|
[<timestamp>] This is a console log from a server component page
|
|
[<timestamp>]"
|
|
`)
|
|
} else {
|
|
expect(output).toMatchInlineSnapshot(`
|
|
"[<timestamp>] This is a console log from a server component page
|
|
[<timestamp>] This is a console log from a server component page
|
|
[<timestamp>] Collecting build traces ...
|
|
[<timestamp>]"
|
|
`)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
})
|
|
})
|