Skip to content

Commit b57df94

Browse files
committed
test(env): fix another CI test failure on GitHub Actions
Same issue - on CI systems, the CI environment variable exists in process.env, so after clearEnv('CI'), getCI() was falling back to process.env.CI. Fixed by using vi.stubEnv to clear the actual CI environment variable.
1 parent df9773a commit b57df94

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/unit/env/ci.test.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import { getCI } from '@socketsecurity/lib/env/ci'
1212
import { clearEnv, resetEnv, setEnv } from '@socketsecurity/lib/env/rewire'
13-
import { afterEach, describe, expect, it } from 'vitest'
13+
import { afterEach, describe, expect, it, vi } from 'vitest'
1414

1515
describe('env/ci', () => {
1616
afterEach(() => {
@@ -90,8 +90,11 @@ describe('env/ci', () => {
9090
setEnv('CI', 'true')
9191
expect(getCI()).toBe(true)
9292

93+
// On CI systems, process.env.CI exists, so stub it out first
94+
vi.stubEnv('CI', undefined)
9395
clearEnv('CI')
9496
expect(getCI()).toBe(false)
97+
vi.unstubAllEnvs()
9598
})
9699

97100
it('should handle consecutive reads', () => {

0 commit comments

Comments
 (0)