Skip to content

Commit f1caf1e

Browse files
edelaunaRoo Code
authored andcommitted
fixup! fix(vitest4): migrate tests and configs for vitest 4 compatibility
1 parent b72d3a9 commit f1caf1e

152 files changed

Lines changed: 1972 additions & 1384 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/cli/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default defineConfig({
1616
coverage: {
1717
provider: "v8",
1818
reporter: ["text", "lcov"],
19+
include: ["src/**/*.ts", "src/**/*.tsx"],
1920
exclude: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "**/vitest.config.ts"],
2021
},
2122
},

packages/cloud/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
coverage: {
99
provider: "v8",
1010
reporter: ["text", "lcov"],
11+
include: ["src/**/*.ts", "src/**/*.tsx"],
1112
exclude: [
1213
"**/*.test.ts",
1314
"**/*.test.tsx",

packages/core/src/worktree/__tests__/worktree-include.integration.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe.sequential("WorktreeIncludeService integration", () => {
3838
await execGit(repoDir, ["init"])
3939
await execGit(repoDir, ["config", "user.name", "Test User"])
4040
await execGit(repoDir, ["config", "user.email", "test@example.com"])
41+
await execGit(repoDir, ["config", "commit.gpgSign", "false"])
4142

4243
await fs.writeFile(path.join(repoDir, "README.md"), "test")
4344
await execGit(repoDir, ["add", "README.md"])

packages/core/src/worktree/__tests__/worktree-service.integration.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe.sequential("WorktreeService integration", () => {
2828
await execGit(repoDir, ["init"])
2929
await execGit(repoDir, ["config", "user.name", "Test User"])
3030
await execGit(repoDir, ["config", "user.email", "test@example.com"])
31+
await execGit(repoDir, ["config", "commit.gpgSign", "false"])
3132
await fs.writeFile(path.join(repoDir, "README.md"), "base")
3233
await execGit(repoDir, ["add", "README.md"])
3334
await execGit(repoDir, ["commit", "-m", "init"])

packages/core/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
coverage: {
99
provider: "v8",
1010
reporter: ["text", "lcov"],
11+
include: ["src/**/*.ts", "src/**/*.tsx"],
1112
exclude: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "**/vitest.config.ts"],
1213
},
1314
},

packages/ipc/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"extends": "@roo-code/config-typescript/base.json",
3+
"compilerOptions": {
4+
"types": ["node"]
5+
},
36
"include": ["src"],
47
"exclude": ["node_modules"]
58
}

packages/telemetry/src/__tests__/PostHogTelemetryClient.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ describe("PostHogTelemetryClient", () => {
3737
optOut: vi.fn(),
3838
shutdown: vi.fn().mockResolvedValue(undefined),
3939
}
40-
;(PostHog as any).mockImplementation(() => mockPostHogClient)
40+
;(PostHog as any).mockImplementation(function () {
41+
return mockPostHogClient
42+
})
4143

4244
// @ts-expect-error - Accessing private static property for testing
4345
PostHogTelemetryClient._instance = undefined

packages/telemetry/vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
coverage: {
99
provider: "v8",
1010
reporter: ["text", "lcov"],
11+
include: ["src/**/*.ts", "src/**/*.tsx"],
1112
exclude: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "**/vitest.config.ts"],
1213
},
1314
},

src/__tests__/extension.spec.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,21 @@ vi.mock("../utils/autoImportSettings", () => ({
158158
}))
159159

160160
vi.mock("../extension/api", () => ({
161-
API: vi.fn().mockImplementation(() => ({})),
161+
API: vi.fn().mockImplementation(function () {
162+
return {}
163+
}),
162164
}))
163165

164166
vi.mock("../activate", () => ({
165167
handleUri: vi.fn(),
166168
registerCommands: vi.fn(),
167169
registerCodeActions: vi.fn(),
168170
registerTerminalActions: vi.fn(),
169-
CodeActionProvider: vi.fn().mockImplementation(() => ({
170-
providedCodeActionKinds: [],
171-
})),
171+
CodeActionProvider: vi.fn().mockImplementation(function () {
172+
return {
173+
providedCodeActionKinds: [],
174+
}
175+
}),
172176
}))
173177

174178
vi.mock("../i18n", () => ({
@@ -192,7 +196,9 @@ vi.mock("../core/webview/ClineProvider", async () => {
192196
}
193197
return {
194198
ClineProvider: Object.assign(
195-
vi.fn().mockImplementation(() => mockInstance),
199+
vi.fn().mockImplementation(function () {
200+
return mockInstance
201+
}),
196202
{
197203
// Static method used by extension.ts
198204
getVisibleInstance: vi.fn().mockReturnValue(mockInstance),

src/activate/__tests__/CodeActionProvider.spec.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ vi.mock("../../i18n", () => ({
1818
}))
1919

2020
vi.mock("vscode", () => ({
21-
CodeAction: vi.fn().mockImplementation((title, kind) => ({
22-
title,
23-
kind,
24-
command: undefined,
25-
})),
21+
CodeAction: vi.fn().mockImplementation(function (title, kind) {
22+
return {
23+
title,
24+
kind,
25+
command: undefined,
26+
}
27+
}),
2628
CodeActionKind: {
2729
QuickFix: { value: "quickfix" },
2830
RefactorRewrite: { value: "refactor.rewrite" },
2931
},
30-
Range: vi.fn().mockImplementation((startLine, startChar, endLine, endChar) => ({
31-
start: { line: startLine, character: startChar },
32-
end: { line: endLine, character: endChar },
33-
})),
32+
Range: vi.fn().mockImplementation(function (startLine, startChar, endLine, endChar) {
33+
return {
34+
start: { line: startLine, character: startChar },
35+
end: { line: endLine, character: endChar },
36+
}
37+
}),
3438
DiagnosticSeverity: {
3539
Error: 0,
3640
Warning: 1,
@@ -78,7 +82,9 @@ describe("CodeActionProvider", () => {
7882
})
7983
;(EditorUtils.getFilePath as Mock).mockReturnValue("/test/file.ts")
8084
;(EditorUtils.hasIntersectingRange as Mock).mockReturnValue(true)
81-
;(EditorUtils.createDiagnosticData as Mock).mockImplementation((d) => d)
85+
;(EditorUtils.createDiagnosticData as Mock).mockImplementation((d) => {
86+
return d
87+
})
8288
})
8389

8490
describe("provideCodeActions", () => {
@@ -127,15 +133,15 @@ describe("CodeActionProvider", () => {
127133
})
128134

129135
it("should handle errors gracefully", () => {
130-
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {})
136+
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(function () {})
131137

132138
// Reset the workspace mock to return true for enableCodeActions
133139
const mockGet = vi.fn().mockReturnValue(true)
134140
const mockGetConfiguration = vi.fn().mockReturnValue({
135141
get: mockGet,
136142
})
137143
;(vscode.workspace.getConfiguration as Mock).mockReturnValue(mockGetConfiguration())
138-
;(EditorUtils.getEffectiveRange as Mock).mockImplementation(() => {
144+
;(EditorUtils.getEffectiveRange as Mock).mockImplementation(function () {
139145
throw new Error("Test error")
140146
})
141147

0 commit comments

Comments
 (0)