Repository navigation
test(infra): resolve the real tokens under vitest instead of a drifted stub (#944) - #947
Merged
Merged
Conversation
…d stub (#944) Closes #944. `vitest.config.ts` aliased `@scaffald/ui/tokens` to a hand-maintained stub. There was never a technical reason for it — `packages/ui/src/tokens` is plain data modules with no react-native, expo, Platform or Dimensions import between them, so they load in jsdom as-is. The alias now points at the source and the stub is deleted. It had drifted from production in both directions: - Its `borderRadius` was still the PRE-#621 scale (xs 6, s 8, l 12, xl 16) against the real 2 / 4 / 7. Nothing asserted on those numbers, which is the only reason it went unnoticed — any test that started asserting a radius would have asserted the wrong one and looked right. - It carried a `slate` ramp the real tokens do not have, and lacked `zinc`, which they do. So `colors.slate[500]` passed every test and was `undefined` in the app. A stub more permissive than reality is the dangerous direction; nothing in the repo turned out to depend on `slate`. The missing direction is what surfaced it: a real token absent from the stub reads as `undefined`, and at module scope it kills the whole suite on import with a stack pointing at the feature file, so the first guess is that the feature code is wrong. That cost a detour during #820. `packages/scf-core/__tests__/tokens-alias-is-real.test.ts` is the guard, next to the other two tests that police the test infrastructure. Verified that it actually guards rather than merely passing: pointed the alias at a stub shaped like the old one and all five assertions failed; pointed it back and all five passed. 8 projects, 2137 tests, 0 failures (scf-core 1272, ui 714, app 98, schemas 53). `@scaffald/integration-test` fails for want of a local Supabase on :54321 — reproduced identically on unmodified main, and it is excluded from every repo script including `test:unit` and `check`. Co-Authored-By: Claude Opus 5 <[email protected]>
Closed
5 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #944. Clears the way for #833, whose whole job is auditing these tokens in dark.
What changed
vitest.config.tsaliased@scaffald/ui/tokensto a hand-maintained stub. The alias now points atpackages/ui/src/tokensand the stub is deleted — 226 lines of it.There was never a technical reason for the stub. The token modules are plain data with no
react-native,expo,PlatformorDimensionsimport between them, so they load in jsdom as-is. Its git history is a series of commits called "expand token mock" and "expand beyond-ui token coverage" — people hitting a missing token and adding it by hand, one at a time.It had drifted both ways
borderRadiusxxs 2, xs 4, s 4, m 4, l 7, xl 7, xxl 7xxs 4, xs 6, s 8, m 10, l 12, xl 16, xxl 20zincslate, and nozincThe radius scale was the pre-#621 one. Nothing asserts on those numbers today, which is the only reason it went unnoticed — but any test that started asserting a radius would have asserted the wrong one and looked correct.
slateis the dangerous direction: it existed only in the stub, socolors.slate[500]passed every test and wasundefinedin production. Nothing in the repo turned out to depend on it, so removing it cost nothing.The missing direction is what surfaced this during #820. A real token absent from the stub reads as
undefined, and at module scope it kills the whole suite on import with a stack pointing at the feature file:Lines 78 and 79 of the same object literal resolved fine, because the stub happened to carry
amberandemerald. So the first guess is always that the feature code is wrong.The guard, and proof that it guards
packages/scf-core/__tests__/tokens-alias-is-real.test.tssits beside the two existing tests that police the test infrastructure (no-duplicate-vi-mock,vi-mock-paths-resolve). It asserts the real radius scale, the six-step type scale, thatzincresolves, thatslatedoes not, and thattext[theme].quaternaryflips.A guard that passes proves nothing on its own, so I pointed the alias at a stub shaped like the old one:
Pointed it back: 5 passed. Then removed the temporary stub.
Verification
8 projects, 2137 tests, 0 failures — scf-core 1272, ui 714, app 98, schemas 53. Every suite now runs against production token values, and none of them needed changing, which is the useful finding: no test was quietly relying on the stub's wrong numbers.
@scaffald/integration-testfails for want of a local Supabase on :54321 (Docker isn't running here). I reproduced that on unmodified main before attributing it, and it is excluded from every repo script includingtest:unitandcheck.pnpm prepushgreen.Note on the diff
vitest.config.tsis 13 changed lines, not 118. My first commit ranbiome check --writeon it, which rewrote the whole file's quote style and semicolons — the file is double-quoted on main and biome's config prefers single. That is pure churn in a config other sessions touch, so I reverted it and re-applied the alias change by hand.🤖 Generated with Claude Code