Skip to content

Commit 21a981f

Browse files
authored
fix(test): stub NODE_ENV in the chat utils tests instead of replacing process (#10597)
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.
1 parent 6c4ea4b commit 21a981f

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎apps/sim/app/api/chat/utils.test.ts‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
workflowsUtilsMock,
1313
} from '@sim/testing'
1414
import { rateLimiterMock, rateLimiterMockFns } from '@sim/testing/mocks/rate-limiter.mock'
15-
import { beforeEach, describe, expect, it, vi } from 'vitest'
15+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1616

1717
const {
1818
mockMergeSubblockStateWithValues,
@@ -67,13 +67,11 @@ mockCheckRateLimitDirect.mockResolvedValue({ allowed: true })
6767

6868
describe('Chat API Utils', () => {
6969
beforeEach(() => {
70-
vi.stubGlobal('process', {
71-
...process,
72-
env: {
73-
...process.env,
74-
NODE_ENV: 'development',
75-
},
76-
})
70+
vi.stubEnv('NODE_ENV', 'development')
71+
})
72+
73+
afterEach(() => {
74+
vi.unstubAllEnvs()
7775
})
7876

7977
describe('Auth token utils', () => {

0 commit comments

Comments
 (0)