Skip to content

Commit c8d16ca

Browse files
committed
fix: Add missing vscode mock method and execa mock for McpHub tests
- Added createTextEditorDecorationType to vscode mock in McpHub.test.ts - Created execa mock to handle ESM module import issues - Fixes test failure that was exposed by PR #4267's module loading changes
1 parent efe7363 commit c8d16ca

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/__mocks__/execa.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const execa = jest.fn().mockResolvedValue({
2+
stdout: "",
3+
stderr: "",
4+
exitCode: 0,
5+
failed: false,
6+
killed: false,
7+
signal: null,
8+
timedOut: false,
9+
})
10+
11+
class ExecaError extends Error {
12+
constructor(message) {
13+
super(message)
14+
this.name = "ExecaError"
15+
this.exitCode = 1
16+
this.stdout = ""
17+
this.stderr = message
18+
this.failed = true
19+
this.timedOut = false
20+
this.isCanceled = false
21+
this.killed = false
22+
this.signal = null
23+
}
24+
}
25+
26+
module.exports = {
27+
execa,
28+
ExecaError,
29+
}

src/services/mcp/__tests__/McpHub.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jest.mock("vscode", () => ({
2222
showErrorMessage: jest.fn(),
2323
showInformationMessage: jest.fn(),
2424
showWarningMessage: jest.fn(),
25+
createTextEditorDecorationType: jest.fn().mockReturnValue({
26+
dispose: jest.fn(),
27+
}),
2528
},
2629
Disposable: {
2730
from: jest.fn(),

0 commit comments

Comments
 (0)