Skip to content

Commit 0bd76ea

Browse files
fix(ui): pin NODE_ENV=test in vitest config so prod env shells pass (RAN-40) (#81)
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>
1 parent 742c839 commit 0bd76ea

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ui/vitest.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { defineConfig } from "vitest/config";
22
import react from "@vitejs/plugin-react";
33
import { resolve } from "path";
44

5+
// React 19's CJS entry picks production vs development at require-time off
6+
// NODE_ENV; the production build omits `act`. Force the test build before any
7+
// worker forks so callers with NODE_ENV=production (CI-adjacent shells, the
8+
// Paperclip agent harness) get the same result as bare `npm test`.
9+
process.env.NODE_ENV = "test";
10+
511
export default defineConfig({
612
plugins: [react()],
713
resolve: {

0 commit comments

Comments
 (0)