Skip to content

Commit 55c391d

Browse files
chore: upgrade vitest to v4 (#1115)
* chore: upgrade vitest to v4 and fix breaking test changes Upgrade vitest from v2 to v4.1.4 across all packages, and vitest-mock-extended from v3 to v4.0.0. Fix constructor mock tests that used arrow functions (now require function/class keyword in Vitest 4) and explicit fs mock factory for Node built-in auto-mocking changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: add CHANGELOG entry for vitest v4 upgrade Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * changelog --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ca8a0d3 commit 55c391d

File tree

7 files changed

+587
-479
lines changed

7 files changed

+587
-479
lines changed

packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"tsc-watch": "^6.2.0",
2020
"tsx": "^4.19.1",
2121
"typescript": "^5.6.2",
22-
"vitest": "^2.1.9"
22+
"vitest": "^4.1.4"
2323
},
2424
"dependencies": {
2525
"@coderabbitai/bitbucket": "^1.1.3",

packages/backend/src/repoIndexManager.test.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,19 @@ const mockWorkerClose = vi.fn().mockResolvedValue(undefined);
9090
const mockWorkerOn = vi.fn();
9191

9292
vi.mock('bullmq', () => ({
93-
Queue: vi.fn().mockImplementation(() => ({
94-
add: mockQueueAdd,
95-
close: mockQueueClose,
96-
})),
97-
Worker: vi.fn().mockImplementation((_name: string, processor: unknown) => ({
98-
on: mockWorkerOn,
99-
close: mockWorkerClose,
100-
processJob: processor,
101-
})),
93+
Queue: vi.fn().mockImplementation(function () {
94+
return {
95+
add: mockQueueAdd,
96+
close: mockQueueClose,
97+
};
98+
}),
99+
Worker: vi.fn().mockImplementation(function (_name: string, processor: unknown) {
100+
return {
101+
on: mockWorkerOn,
102+
close: mockWorkerClose,
103+
processJob: processor,
104+
};
105+
}),
102106
DelayedError: class DelayedError extends Error {
103107
constructor(message: string) {
104108
super(message);
@@ -110,9 +114,11 @@ vi.mock('bullmq', () => ({
110114
// Mock Redlock
111115
const mockRedlockUsing = vi.fn();
112116
vi.mock('redlock', () => ({
113-
default: vi.fn().mockImplementation(() => ({
114-
using: mockRedlockUsing,
115-
})),
117+
default: vi.fn().mockImplementation(function () {
118+
return {
119+
using: mockRedlockUsing,
120+
};
121+
}),
116122
ExecutionError: class ExecutionError extends Error {
117123
constructor(message: string) {
118124
super(message);

packages/queryLanguage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@lezer/generator": "^1.8.0",
1212
"tsx": "^4.19.1",
1313
"typescript": "^5.7.3",
14-
"vitest": "^2.1.9"
14+
"vitest": "^4.1.4"
1515
},
1616
"dependencies": {
1717
"@lezer/common": "^1.3.0",

packages/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"tsc-watch": "6.2.1",
3232
"tsx": "^4.19.1",
3333
"typescript": "^5.7.3",
34-
"vitest": "^2.1.9"
34+
"vitest": "^4.1.4"
3535
},
3636
"exports": {
3737
".": "./dist/index.server.js",

packages/web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@
227227
"typescript": "^5",
228228
"typescript-eslint": "^8.56.1",
229229
"vite-tsconfig-paths": "^5.1.3",
230-
"vitest": "^2.1.5",
231-
"vitest-mock-extended": "^3.1.0"
230+
"vitest": "^4.1.4",
231+
"vitest-mock-extended": "^4.0.0"
232232
},
233233
"resolutions": {
234234
"@types/react": "19.2.14",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import * as dateUtils from './dateUtils';
44

55
// Mock dependencies
66
vi.mock('simple-git');
7-
vi.mock('fs');
7+
vi.mock('fs', () => ({
8+
existsSync: vi.fn().mockReturnValue(true),
9+
}));
810
vi.mock('@sourcebot/shared', () => ({
911
REPOS_CACHE_DIR: '/mock/cache/dir',
1012
getRepoPath: (repo: { id: number }) => ({

0 commit comments

Comments
 (0)