Skip to content

Commit 11184ea

Browse files
msukkariclaude
andcommitted
fix(web): mock @sourcebot/shared in utils.test.ts to fix server env error
The test was failing because importing utils.ts transitively pulled in server-side environment variables via createLogger, which crashes in the jsdom test environment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 825781f commit 11184ea

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/web/src/features/git/utils.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
import { expect, test } from 'vitest';
1+
import { expect, test, vi } from 'vitest';
2+
3+
vi.mock('@sourcebot/shared', () => ({
4+
createLogger: () => ({
5+
debug: vi.fn(),
6+
info: vi.fn(),
7+
warn: vi.fn(),
8+
error: vi.fn(),
9+
}),
10+
}));
11+
212
import { buildFileTree, isPathValid, normalizePath } from './utils';
313

414
test('normalizePath adds a trailing slash and strips leading slashes', () => {

0 commit comments

Comments
 (0)