Skip to content

Commit 88df82d

Browse files
committed
fix(test): update tests for read-only ENV properties from @socketsecurity/lib
After migrating to @socketsecurity/lib environment helpers, ENV properties became read-only getters. Tests must now manipulate process.env directly instead of trying to set ENV properties. Changes: - flags.test.mts: Use process.env.NODE_OPTIONS instead of ENV.NODE_OPTIONS - shadow tests: Fix SOCKET_CLI_ACCEPT_RISKS filter expectations When acceptRisks=true, filter should be { actions: ['error'], blocked: true } not { actions: ['error', 'monitor', 'warn'] }
1 parent fb2593d commit 88df82d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

packages/cli/src/flags.test.mts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ describe('flags', () => {
4040
beforeEach(() => {
4141
vi.clearAllMocks()
4242
resetFlagCache()
43-
// Save original argv and reset ENV for clean state.
43+
// Save original argv and reset NODE_OPTIONS for clean state.
4444
originalArgv = process.argv
45-
ENV.NODE_OPTIONS = ''
45+
process.env.NODE_OPTIONS = ''
4646
})
4747

4848
afterEach(() => {
4949
// Restore original state.
5050
process.argv = originalArgv
51-
ENV.NODE_OPTIONS = ''
51+
delete process.env.NODE_OPTIONS
5252
})
5353

5454
describe('getMaxOldSpaceSizeFlag', () => {
@@ -61,14 +61,14 @@ describe('flags', () => {
6161
})
6262

6363
it('respects NODE_OPTIONS', () => {
64-
ENV.NODE_OPTIONS = '--max-old-space-size=512'
64+
process.env.NODE_OPTIONS = '--max-old-space-size=512'
6565
resetFlagCache()
6666

6767
const result = getMaxOldSpaceSizeFlag()
6868
expect(result).toBe(512)
6969

7070
// Cleanup.
71-
ENV.NODE_OPTIONS = ''
71+
delete process.env.NODE_OPTIONS
7272
})
7373

7474
it('respects user-provided flag', () => {
@@ -106,14 +106,14 @@ describe('flags', () => {
106106
})
107107

108108
it('respects NODE_OPTIONS', () => {
109-
ENV.NODE_OPTIONS = '--max-semi-space-size=16'
109+
process.env.NODE_OPTIONS = '--max-semi-space-size=16'
110110
resetFlagCache()
111111

112112
const result = getMaxSemiSpaceSizeFlag()
113113
expect(result).toBe(16)
114114

115115
// Cleanup.
116-
ENV.NODE_OPTIONS = ''
116+
delete process.env.NODE_OPTIONS
117117
})
118118

119119
it('respects user-provided flag', () => {

packages/cli/src/shadow/pnpm/bin.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('shadowPnpm', () => {
201201
expect(mockGetAlertsMapFromPurls).toHaveBeenCalledWith(
202202
['pkg:npm/lodash'],
203203
expect.objectContaining({
204-
filter: { actions: ['error', 'monitor', 'warn'] },
204+
filter: { actions: ['error'], blocked: true },
205205
nothrow: true,
206206
}),
207207
)

packages/cli/src/shadow/yarn/bin.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('shadowYarn', () => {
218218
expect(mockGetAlertsMapFromPurls).toHaveBeenCalledWith(
219219
['pkg:npm/lodash'],
220220
expect.objectContaining({
221-
filter: { actions: ['error', 'monitor', 'warn'] },
221+
filter: { actions: ['error'], blocked: true },
222222
nothrow: true,
223223
}),
224224
)

0 commit comments

Comments
 (0)