Skip to content

fix(test): stub NODE_ENV in the chat utils tests instead of replacing process - #10597

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/chat-utils-test-stub-env
Dec 1, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/chat-utils-test-stub-env

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator
  • Staging checks / test (2/2) has failed since c01a6f4 (chore(ci): record which unit tests a change reaches, without skipping any #10593) on app/api/chat/utils.test.ts: TypeError: process.on is not a function (all 8 tests pass; the file fails on an error outside them).
  • Cause: the test did vi.stubGlobal('process', { ...process, env: {...} }); spreading process drops its EventEmitter methods. chore(ci): record which unit tests a change reaches, without skipping any #10593's Blacksmith vitest plugin (CI only, GITHUB_ACTIONS=true) calls process.on during the run.
  • Fix: vi.stubEnv('NODE_ENV', 'development') plus vi.unstubAllEnvs() after each test (the old stub was never restored either). It was the only test replacing process.
  • Verified locally with GITHUB_ACTIONS=true: staging's version fails with the same TypeError; this version passes (8/8).

… process

The test replaced the global process with a spread copy, which drops
EventEmitter methods such as process.on. Since #10593 added the Blacksmith
vitest plugin in CI (GITHUB_ACTIONS=true), the run calls process.on during the
file and test shard 2/2 failed with "process.on is not a function". Stub only
the env var, and restore it after each test.
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 9:04pm UTC

Request Review

@waleedlatif1
waleedlatif1 merged commit 21a981f into staging Dec 1, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-utils-test-stub-env branch December 1, 2026 21:04
@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Low impact] The change is limited to setup and cleanup in one test suite.

Remove the extra cleanup hook before merging to satisfy the repository’s testing rule.

Findings

  1. P2 Cleanup breaks the testing rule ▶

Summary

This PR replaces the copied process object with a focused NODE_ENV stub in the chat utility tests.

  • Chat utility tests set development mode without replacing process.

Reviews (1) · Last reviewed commit: "fix(test): stub NODE_ENV in the chat uti..." · Reviewed by Greptile

Comment thread apps/sim/app/api/chat/utils.test.ts Resolved
waleedlatif1 added a commit that referenced this pull request Dec 1, 2026
…tests (#10598)

The shared vitest config already restores stubbed env values before every
test, and check:test-patterns forbids vi.unstubAll*() in hooks; #10597's hook
turned staging's lint red.

This branch was previously deployed

1 inactive deployment
Preview — 6f6e252e Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant