Skip to content

Commit 58450a7

Browse files
committed
test: fix npm install test constant mocks (2 tests)
Fixed mock import paths to match refactored constant structure. The implementation was refactored to import from individual constant files (constants/paths.mts, constants/env.mts, etc.) instead of a combined constants.mts file. Updated test mocks to match the new import structure by creating separate mocks for each constants file. Tests fixed: 2 Total tests fixed: 142
1 parent d865d4a commit 58450a7

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

packages/cli/src/shadow/npm/install.test.mts

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,36 @@ vi.mock('../../utils/npm/paths.mts', () => ({
3131
getNpmBinPath: mockGetNpmBinPath,
3232
}))
3333

34-
vi.mock('../../constants.mts', async importOriginal => {
35-
const actual = (await importOriginal()) as Record<string, any>
36-
return {
37-
...actual,
38-
default: {
39-
...actual?.default,
40-
execPath: '/usr/bin/node',
41-
shadowNpmInjectPath: '/mock/inject.js',
42-
instrumentWithSentryPath: '/mock/sentry.js',
43-
nodeNoWarningsFlags: ['--no-warnings'],
44-
nodeDebugFlags: ['--inspect=0'],
45-
nodeHardenFlags: ['--frozen-intrinsics'],
46-
nodeMemoryFlags: [],
47-
processEnv: { SOCKET_ENV: 'test' },
48-
ENV: {
49-
INLINED_SOCKET_CLI_SENTRY_BUILD: false,
50-
},
51-
SOCKET_IPC_HANDSHAKE: 'SOCKET_IPC_HANDSHAKE',
52-
SOCKET_CLI_SHADOW_BIN: 'SOCKET_CLI_SHADOW_BIN',
53-
SOCKET_CLI_SHADOW_PROGRESS: 'SOCKET_CLI_SHADOW_PROGRESS',
54-
},
55-
NPM: 'npm',
56-
FLAG_LOGLEVEL: '--loglevel',
57-
}
58-
})
34+
vi.mock('../../constants/paths.mts', () => ({
35+
execPath: '/usr/bin/node',
36+
instrumentWithSentryPath: '/mock/sentry.js',
37+
nodeDebugFlags: ['--inspect=0'],
38+
nodeHardenFlags: ['--frozen-intrinsics'],
39+
nodeMemoryFlags: [],
40+
nodeNoWarningsFlags: ['--no-warnings'],
41+
shadowNpmInjectPath: '/mock/inject.js',
42+
}))
43+
44+
vi.mock('../../constants/env.mts', () => ({
45+
default: {
46+
INLINED_SOCKET_CLI_SENTRY_BUILD: false,
47+
},
48+
processEnv: { SOCKET_ENV: 'test' },
49+
}))
50+
51+
vi.mock('../../constants/shadow.mts', () => ({
52+
SOCKET_CLI_SHADOW_BIN: 'SOCKET_CLI_SHADOW_BIN',
53+
SOCKET_CLI_SHADOW_PROGRESS: 'SOCKET_CLI_SHADOW_PROGRESS',
54+
SOCKET_IPC_HANDSHAKE: 'SOCKET_IPC_HANDSHAKE',
55+
}))
56+
57+
vi.mock('../../constants/agents.mts', () => ({
58+
NPM: 'npm',
59+
}))
60+
61+
vi.mock('../../constants/cli.mts', () => ({
62+
FLAG_LOGLEVEL: '--loglevel',
63+
}))
5964

6065
describe('shadowNpmInstall', () => {
6166
const mockProcess = {

0 commit comments

Comments
 (0)