Files
pnpm/pnpm11/testing
Zoltan Kochan 719f62f102 test: type the install option helpers so a stale key cannot pass (#13951)
A test's options object is the entire input to the subject under test, so a
key nothing reads does not fail: it quietly runs the default instead of the
case the test is named for. Both install helpers accepted anything — the
headless one took `opts?: any`, and the install one takes `opts?: T & {...}`,
where an unknown key is absorbed into the inferred `T`. That is how the
`registries` -> `registriesByScope` rename left seven suites pointed at the
wrong registry with a green type-check, and only CI to say so.

The headless helper now takes a `Partial<HeadlessOptions>`. Everything that
surfaced was real:

- Seven fields `HeadlessOptions` requires and reads — `configByUri`,
  `globalVirtualStoreDir`, `pruneStore`, `sideEffectsCacheRead`/`Write`,
  `userAgent`, `virtualStoreDirMaxLength` — were never set, so every headless
  test ran with them `undefined`. They now carry the values the install
  behaved as.
- `verifyStoreIntegrity` is a package-store option, not a headless one. The
  three tests that "disable" it were setting a key nobody read; it is now
  forwarded to the store.
- `hoistPattern: '*'` and `publicHoistPattern: '*'` are `string[]`. A
  one-character string iterates like a one-element array, which is the only
  reason they worked.
- `development`, `optional`, `production` predate `include`, which the same
  calls already set, and `sideEffectsCache` predates the read/write split.

Constraining the install helper's `T` is a bigger job — 162 errors, mostly
unrelated to options keys — so it keeps its generic and gains a narrow guard
instead: the three renamed keys are declared with a literal type that names
the replacement. It caught one more live case on the way in.
2026-08-17 02:19:30 +02:00
..