Repository navigation
Commit 20d92e3
ci(test-alias): gate that a unit test judges source, not a sibling's dist (#7966)
Every publishable package resolves through `exports` to `dist/`, so a package
whose tests import a workspace dependency with no vitest source alias is
reporting on build state rather than on the source in the checkout. #7668 is
the loud version of that: 17 cases erroring on a symbol its prebuilt core
predated. The version this gate is aimed at is silent — a dist merely BEHIND
the source runs GREEN against old behaviour, with nothing in the output saying
so.
Demonstrated on this repo before writing the gate: with `@objectstack/spec`
unaliased, `packages/qa/downstream-contract` — the frozen third-party fixture
that exists to catch breaking spec changes — reported 14/14 green against a
spec source that rejected its own fixture outright. Aliasing spec to source on
the identical tree turned it red naming the injected field. Both edits were
reverted.
The gate walks each package's test-reachable imports (type-only imports
excluded — they never resolve), keeps the deps whose own entry point is a
build artifact, and resolves each specifier through the package's vitest
aliases the way Vite does (in order, first match wins, string `find` by
prefix). It also fails the prefix/ENOTDIR trap #7778 documented, since it
performs the real replacement and can see a path running through a file.
`KNOWN_UNALIASED_TEST_IMPORTS` is the measured state: 63 of 72 packages with
tests, 312 package-dependency pairs. It is shrink-only and audited in both
directions, so an entry that is no longer needed fails and names itself for
deletion. Each entry carries its exact dependency set rather than a bare
package name, so a listed package cannot acquire new artifact imports with
nothing going red. No package's vitest config is touched here; per-package
remediation is filed separately.
Claude-Session: https://claude.ai/code/session_01CD4dmUPWszMro2K4Mwzpwj
Co-authored-by: Claude <noreply@anthropic.com>1 parent 551f899 commit 20d92e3
3 files changed
Lines changed: 1179 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
569 | 590 | | |
570 | 591 | | |
571 | 592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
0 commit comments