Repository navigation
fix(test): make the scf-core suites load, run, and complete - #507
Merged
Merged
Conversation
Six suites in scf-core were reporting zero tests or dying on the first render.
None of it was a bad assertion — four infrastructure faults, three of which had
nothing to do with the tests themselves.
1. expo ships raw TypeScript, not compiled JS: package.json points main/module
at src/Expo.ts and build/ holds only .d.ts. So Expo.fx.tsx -> ./winter ->
runtime.ts executes, and that file wires up Fast Refresh, HMR and the Metro
message socket with bare CommonJS `require('./setupFastRefresh')` calls on
.ts siblings. Vitest transforms the module to ESM but leaves the requires,
and Node cannot resolve an extensionless .ts at runtime. Any test importing
expo aborted before running.
Stubbed at ./winter specifically. A require() left in transformed output is
executed by Node and never reaches Vite's resolver — only the ESM import is
interceptable, which is why aliasing the deeper modules silently did nothing.
Nothing is lost: the winter polyfills (FormData, TextDecoder, URL, ...) are
separate modules imported elsewhere; the index pulls in the runtime alone.
2. react-native-safe-area-context resolved to its raw src/ rather than its
compiled build, so the TS-only `typeof` type query in SafeArea.types.ts
reached Node as JS: "Unexpected token 'typeof'". Pinned to lib/module — the
real module, not a mock, so behaviour is unchanged.
3. useBottomBarContext was missing from the @scaffald/ui mock. The real hook
reads a context with a default and never throws, but vitest turns an absent
export on a mocked module into a hard error, so every suite rendering a
dashboard screen died.
4. profile-employment-left.test.tsx declared vi.mock("@scaffald/ui") three
times. Only one registration survives per module path and the survivor
exported useToast alone — hence `No "Stack" export`. The other two blocks
(185 and 274 lines) were dead. Consolidated to one.
Plus: SafeAreaProvider needs seeded initialMetrics because jsdom never measures
a frame, and ApplicationWizard's nine renders had no QueryClientProvider.
wizards (ipip/riasec/occupation) 0 tests -> 7 passed, 10 pre-existing skips
ApplicationWizard 9 failed -> 9 passed
profile-employment-left 36 failed -> 40 passed
ResultsRail 0 tests -> 2 passed
MapSearchInput, WorkerPreviewModal, ResumeImportWidget: green off the shared fixes
Four of the five files here are shared test infrastructure imported by every
suite in the repo, so the risk was regression elsewhere. Verified: pnpm test:unit
exit 0 across 6 projects, pnpm check exit 0 (lint 10/10, typecheck 12/12).
NOT un-excluding scf-core from affected:test/test:unit/prepush, which was the
original goal. A full run OOMs (SIGABRT) at both 4 GB and 8 GB — pool: "threads"
shares heap across 329 files and nothing is reclaimed between them. That is
pre-existing and structural; these fixes accelerate it only because three files
that used to abort for free now render real trees. Filed as #504. Un-excluding a
suite that cannot complete would trade an invisible problem for a permanently
red gate, which is the mistake #492 removed.
Co-Authored-By: Claude Opus 5 <[email protected]>
The root config uses `pool: "threads"`, which shares one heap across every file. Over this project's 333 test files nothing is reclaimed between them and the run dies with a JS heap OOM (SIGABRT) at both 4 GB and 8 GB — no assertion fails, the process simply runs out of memory. That is why scf-core is excluded from every aggregate command: it could never finish. Forks give each file its own process, so its heap is released on exit. Verified by direct vitest invocation: vitest run --config packages/scf-core/vitest.config.ts --pool=forks --maxWorkers=2 921 tests | 829 passed | 31 failed | 58 skipped 333 files | 17 failed files A real result instead of a crash, and the first time this suite has reported one. Two caveats, both recorded in #504: - The same run through the nx executor (`nx run scf-core:test`) had not finished after 11 minutes and was killed, so whether `@nx/vitest:test` honours the pool setting is NOT yet confirmed. This is safe to land regardless — scf-core is excluded from every CI path today — but it must be settled before the suite is un-excluded, since CI would invoke it through nx. - 31 tests still fail for real. Biggest clusters are UserProfilePanel (18), MapSearchInput (7) and TeamForm (4). MapSearchInput passes when run in a small group and fails in the full run, which smells of cross-file state leakage rather than a broken assertion. So scf-core stays in the exclusion lists for now. Runnable is the prerequisite; green is what earns the gate. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
Six suites in
scf-corewere reporting zero tests or dying on first render, and thesuite as a whole could never finish. None of it was a bad assertion.
Four infrastructure faults
1.
expoships raw TypeScript, not compiled JS. Itspackage.jsonpointsmain/moduleat
src/Expo.ts, andbuild/holds only.d.ts. SoExpo.fx.tsx → ./winter → runtime.tsexecutes, and that file wires up Fast Refresh, HMR and the Metro message socket with bare
CommonJS
require('./setupFastRefresh')calls on.tssiblings. Vitest transforms the moduleto ESM but leaves the requires, and Node can't resolve an extensionless
.tsat runtime.Stubbed at
./winterspecifically: arequire()left in transformed output is executed byNode and never reaches Vite's resolver — only the ESM
importis interceptable, which is whyaliasing the deeper modules silently did nothing. Nothing is lost; the winter polyfills
(FormData, TextDecoder, URL, …) are separate modules imported elsewhere.
2.
react-native-safe-area-contextresolved to rawsrc/rather than its compiled build,so the TS-only
typeoftype query inSafeArea.types.tsreached Node as JS:Unexpected token 'typeof'. Pinned tolib/module— the real module, not a mock.3.
useBottomBarContextmissing from the@scaffald/uimock. The real hook reads a contextwith a default and never throws, but vitest turns an absent export on a mocked module into a
hard error — so every suite rendering a dashboard screen died.
4.
profile-employment-left.test.tsxdeclaredvi.mock("@scaffald/ui")three times. Onlyone registration survives per module path, and the survivor exported
useToastalone — henceNo "Stack" export. The other two blocks (185 and 274 lines) were dead code.Plus
SafeAreaProviderneeds seededinitialMetrics(jsdom never measures a frame), andApplicationWizard's nine renders had noQueryClientProvider.The OOM
A full run died with a JS heap OOM (SIGABRT) at both 4 GB and 8 GB —
pool: "threads"sharesone heap across 333 files. Switched this project to
pool: 'forks':A real result instead of a crash — the first this suite has ever reported.
Risk, and how it was checked
Four of the six changed files are shared test infrastructure imported by every suite in the
repo (
vitest.config.ts,test-utils.tsx,beyond-ui.tsx). That, not scf-core, was the realrisk:
pnpm test:unitpnpm checkWhat this does NOT do
scf-corestays in the exclusion lists (package.json:12,package.json:158,scripts/prepush.sh:32). Un-excluding was the original goal, and it isn't earned yet:MapSearchInputpasses in a small group and fails in the full run, which smells of cross-filestate leakage rather than a broken assertion.
nx run scf-core:testhadn't finished after 11 minutesand was killed, so whether
@nx/vitest:testhonours the pool setting is an open question. Safeto land regardless — scf-core is in no CI path today — but it must be settled first, since CI
would invoke it through nx.
Un-excluding now would turn an invisible problem into a permanently red gate: the same failure
mode as the 80%-vs-37% coverage threshold removed in #492. Runnable is the prerequisite; green
earns the gate. Both caveats are tracked in #504.
CI
Actions is out of included minutes until the allowance resets on the 1st, so this is verified
locally only. No live services are involved in any of the gates above.
🤖 Generated with Claude Code