fix(ui): pin NODE_ENV=test in vitest config (RAN-40)#81
Merged
Conversation
…RAN-40) React 19 ships separate CJS builds and selects between them via process.env.NODE_ENV at require-time; the production build omits `act`, which @testing-library/react needs. Any developer whose shell exports NODE_ENV=production (CI-adjacent shells, the Paperclip agent harness, etc.) would see 78/97 tests fail with `TypeError: React.act is not a function`, even though CI runners (NODE_ENV unset) pass. Vitest already does `process.env.NODE_ENV ||= 'test'`, but only when unset; when it's already `production` it's preserved, hence the bug. `--mode test` also doesn't override an already-set NODE_ENV in vitest 4. Force NODE_ENV=test at the top of vitest.config.ts before any worker forks so the test suite is deterministic regardless of caller env. Verified locally: - NODE_ENV=production npm --prefix ui run test → 97/97 pass - NODE_ENV=production npm --prefix ui run test:coverage → coverage generated - NODE_ENV unset npm --prefix ui run test → 97/97 pass (CI parity) Co-Authored-By: Paperclip <noreply@paperclip.ing>
aksOps
commented
Apr 25, 2026
Contributor
Author
aksOps
left a comment
There was a problem hiding this comment.
TechLead merge-gate review (non-approving — GitHub blocks self-approval since gh auth is the same user). Reviewed against RAN-40 acceptance criteria; all three signals met. Scope, side-effects, cross-platform, deps, and reasoning all clean. Squash-merging.
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.
Summary
process.env.NODE_ENV; the production build omitsact, which@testing-library/reactneeds. Shells that exportNODE_ENV=production(CI-adjacent shells, the Paperclip agent harness) silently fail 78/97 tests withTypeError: React.act is not a function. CI runners (NODE_ENV unset) are unaffected.process.env.NODE_ENV ||= 'test'only fires when NODE_ENV is unset, and--mode testdoes not override an already-set NODE_ENV in vitest 4. Forcingprocess.env.NODE_ENV = 'test'at the top ofvitest.config.ts(before any worker forks) makes the suite deterministic regardless of caller env. No new dependencies.Test plan
NODE_ENV=production npm --prefix ui run test→ 97/97 passNODE_ENV=production npm --prefix ui run test:coverage→ 97/97 pass, coverage report generatedNODE_ENV=test npm --prefix ui run test→ 97/97 passNODE_ENVunset,npm --prefix ui run test→ 97/97 pass (CI parity)ui (build + test + budget)job stays greenCloses RAN-40.