Files
next.js/test/e2e/app-dir/instant-validation/update-instant-validation-snapshots.mjs
Janka UrygaandGitHub c131314bcf [PP] Validate Shell prefetches (except gSP) (#95151)
Implements instant validation for `partialPrefetching`. In this mode,
`<Link>` prefetches an App Shell, which cannot access link data, and we
need to warn for that.

The changes in `instant-validation.tsx` are relatively simple: for an
App Shell, we simply use `ShellRuntime` for all the new segments. We
might also force them into `Runtime` for the purposes of discriminating
dynamic holes. If a hole is present in `ShellRuntime` but disappears in
`Runtime`, then we know it's caused by **link data** (as opposed to
runtime or dynamic data). I've added some new error messages for this
case.

Note that the implementation here is incomplete: it uses the chunks from
the dev render, which resolves static params in the `Static` stage. We
use `ShellRuntime` for validating the App Shell, so as a result, static
params are incorrectly included in it and don't trigger link data
errors. This will be implemented in a follow-up.

Note: It seems like we have some pre-existing bug in build validation
where `fallbackParams` aren't populated, so params resolve statically
when they shouldn't. I've marked two tests with `// TODO(app-shells):
missing fallback params in build validation` so we can follow up and fix
those.
2026-07-01 02:36:41 +00:00

46 lines
1.0 KiB
JavaScript
Executable File

#!/usr/bin/env node
// @ts-check
import execa from 'execa'
const inputArgs = process.argv.slice(2)
if (!inputArgs.some((arg) => arg === '-u' || arg === '--updateSnapshot')) {
inputArgs.push('-u')
}
const startArgs = [...inputArgs]
// For dev, we need to pass `-t 'initial load'` to avoid problems with multiple snapshots
// Extract any `-t` args passed and prefix them
/** @type {string[]} */
const devArgs = []
/** @type {string | null} */
let testPattern = null
let i = 0
while (i < inputArgs.length) {
if (inputArgs[i] === '-t' || inputArgs[i] === '--testNamePattern') {
testPattern = inputArgs[i + 1]
i += 2
} else {
devArgs.push(inputArgs[i])
i++
}
}
if (testPattern !== null && !testPattern.startsWith('initial load')) {
devArgs.push(`-t`, `initial load.*(${testPattern})`)
} else {
devArgs.push(`-t`, `initial load`)
}
await execa(`pnpm`, [`test-dev-turbo`, ...devArgs], {
stdio: 'inherit',
reject: false,
})
await execa(`pnpm`, [`test-start-turbo`, ...startArgs], {
stdio: 'inherit',
reject: false,
})