Skip to content

Commit 933d1f7

Browse files
committed
chore(ci): Fix failing tests
1 parent 8996d8a commit 933d1f7

16 files changed

Lines changed: 334 additions & 375 deletions

src/utils/__tests__/git-remote.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import {
1818
parseRemoteUrl
1919
} from '../git-remote';
2020

21-
vi.mock('child_process', () => ({ execFileSync: vi.fn() }));
21+
vi.mock('child_process', () => ({
22+
execSync: vi.fn(),
23+
execFileSync: vi.fn(),
24+
spawnSync: vi.fn()
25+
}));
2226

2327
const mockExecFileSync = execFileSync as unknown as {
2428
mock: { calls: unknown[][] };
@@ -386,4 +390,4 @@ describe('git-remote utils', () => {
386390
expect(buildRepoWebUrl(remote)).toBe('https://gitlab.com/group/subgroup/project');
387391
});
388392
});
389-
});
393+
});

src/utils/__tests__/git.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ import {
1717
runGit
1818
} from '../git';
1919

20-
vi.mock('child_process', () => ({ execFileSync: vi.fn() }));
20+
vi.mock('child_process', () => ({
21+
execSync: vi.fn(),
22+
execFileSync: vi.fn(),
23+
spawnSync: vi.fn()
24+
}));
2125

2226
const mockExecFileSync = execFileSync as unknown as {
2327
mock: { calls: unknown[][] };
@@ -378,4 +382,4 @@ describe('git utils', () => {
378382
});
379383
});
380384
});
381-
});
385+
});

src/utils/__tests__/open-url.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import {
1010

1111
import { openExternalUrl } from '../open-url';
1212

13-
vi.mock('child_process', () => ({ spawnSync: vi.fn() }));
13+
vi.mock('child_process', () => ({
14+
execSync: vi.fn(),
15+
execFileSync: vi.fn(),
16+
spawnSync: vi.fn()
17+
}));
1418

1519
const mockSpawnSync = spawnSync as unknown as {
1620
mock: { calls: unknown[][] };

src/utils/__tests__/terminal.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import {
1313
getTerminalWidth
1414
} from '../terminal';
1515

16-
vi.mock('child_process', () => ({ execSync: vi.fn() }));
16+
vi.mock('child_process', () => ({
17+
execSync: vi.fn(),
18+
execFileSync: vi.fn(),
19+
spawnSync: vi.fn()
20+
}));
1721

1822
describe('terminal utils', () => {
1923
const mockExecSync = execSync as unknown as {

src/utils/__tests__/usage-fetch.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { execFileSync } from 'child_process';
1+
import type * as childProcess from 'child_process';
22
import * as fs from 'fs';
3+
import { createRequire } from 'module';
34
import * as os from 'os';
45
import * as path from 'path';
56
import { fileURLToPath } from 'url';
@@ -9,6 +10,9 @@ import {
910
it
1011
} from 'vitest';
1112

13+
const require = createRequire(import.meta.url);
14+
const { execFileSync: realExecFileSync } = require('node:child_process') as { execFileSync: typeof childProcess.execFileSync };
15+
1216
interface UsageProbeResult {
1317
first: Record<string, unknown>;
1418
second: Record<string, unknown>;
@@ -179,7 +183,7 @@ process.stdout.write(JSON.stringify({
179183
}
180184

181185
function runProbe(options: ProbeOptions): UsageProbeResult {
182-
const output = execFileSync(process.execPath, [probeScriptPath], {
186+
const output = realExecFileSync(process.execPath, [probeScriptPath], {
183187
encoding: 'utf8',
184188
env: {
185189
...process.env,

src/utils/__tests__/usage-token-buffer.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212

1313
import { getUsageToken } from '../usage-fetch';
1414

15-
vi.mock('child_process', () => ({ execFileSync: vi.fn() }));
15+
vi.mock('child_process', () => ({
16+
execSync: vi.fn(),
17+
execFileSync: vi.fn(),
18+
spawnSync: vi.fn()
19+
}));
1620

1721
const require = createRequire(import.meta.url);
1822
const { execFileSync: realExecFileSync } = require('node:child_process') as { execFileSync: typeof childProcess.execFileSync };

0 commit comments

Comments
 (0)