Skip to content

Commit 7116e07

Browse files
chore: upgrade vitest to v4.0.14 and update mocks
- Updated vitest version from 3.2.4 to 4.0.14 in package.json files across main, shared, and web packages. - Refactored mock implementations in sqlite-storage.test.ts, route.test.ts for RockPaperScissors and TicTacToe to use 'function' syntax for constructors as required by vitest v4.
1 parent 57b3e44 commit 7116e07

File tree

11 files changed

+158
-329
lines changed

11 files changed

+158
-329
lines changed

mcp-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
"@vitest/ui": "^4.0.14",
2727
"typescript": "^5.9.3",
2828
"typescript-eslint": "^8.48.0",
29-
"vitest": "^3.2.4"
29+
"vitest": "^4.0.14"
3030
}
3131
}

mcp-server/src/integration/integration.test.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,36 @@ vi.mock('../utils/http-client.js', () => ({
1919
}))
2020

2121
// Mock only the game classes from shared library
22+
// In vitest v4, mocks used as constructors must use 'function' syntax
2223
vi.mock('@turn-based-mcp/shared', async (importOriginal) => {
2324
const actual = await importOriginal() as any
2425
return {
2526
...actual,
26-
TicTacToeGame: vi.fn(() => ({
27-
getValidMoves: vi.fn(() => [{ row: 0, col: 0 }])
28-
})),
29-
RockPaperScissorsGame: vi.fn(() => ({}))
27+
TicTacToeGame: vi.fn(function() {
28+
return {
29+
getValidMoves: vi.fn(() => [{ row: 0, col: 0 }])
30+
}
31+
}),
32+
RockPaperScissorsGame: vi.fn(function() { return {} })
3033
}
3134
})
3235

3336
// Mock AI modules
37+
// In vitest v4, mocks used as constructors must use 'function' syntax
3438
vi.mock('../ai/tic-tac-toe-ai.js', () => ({
35-
TicTacToeAI: vi.fn(() => ({
36-
makeMove: vi.fn(() => ({ row: 0, col: 0 }))
37-
}))
39+
TicTacToeAI: vi.fn(function() {
40+
return {
41+
makeMove: vi.fn(() => ({ row: 0, col: 0 }))
42+
}
43+
})
3844
}))
3945

4046
vi.mock('../ai/rock-paper-scissors-ai.js', () => ({
41-
RockPaperScissorsAI: vi.fn(() => ({
42-
makeChoice: vi.fn(() => 'rock')
43-
}))
47+
RockPaperScissorsAI: vi.fn(function() {
48+
return {
49+
makeChoice: vi.fn(() => 'rock')
50+
}
51+
})
4452
}))
4553

4654
describe('MCP Server Integration', () => {

0 commit comments

Comments
 (0)