From 6f6e252e6eb27c25998771a4b3136652a35534d7 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 1 Dec 2026 13:04:24 -0800 Subject: [PATCH] fix(test): stub NODE_ENV in the chat utils tests instead of replacing 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. --- apps/sim/app/api/chat/utils.test.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/sim/app/api/chat/utils.test.ts b/apps/sim/app/api/chat/utils.test.ts index 8e6000c4b82..d4d50da3374 100644 --- a/apps/sim/app/api/chat/utils.test.ts +++ b/apps/sim/app/api/chat/utils.test.ts @@ -12,7 +12,7 @@ import { workflowsUtilsMock, } from '@sim/testing' import { rateLimiterMock, rateLimiterMockFns } from '@sim/testing/mocks/rate-limiter.mock' -import { beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const { mockMergeSubblockStateWithValues, @@ -67,13 +67,11 @@ mockCheckRateLimitDirect.mockResolvedValue({ allowed: true }) describe('Chat API Utils', () => { beforeEach(() => { - vi.stubGlobal('process', { - ...process, - env: { - ...process.env, - NODE_ENV: 'development', - }, - }) + vi.stubEnv('NODE_ENV', 'development') + }) + + afterEach(() => { + vi.unstubAllEnvs() }) describe('Auth token utils', () => {