Skip to content

Commit 13412ba

Browse files
committed
chore: migrate test framework from Jest to Vitest 4.0.15
Replace Jest with Vitest for improved ESM compatibility and faster execution Key changes: - Remove jest, @jest/globals, @types/jest, ts-jest → install vitest 4.0.15 - Convert all test files: jest.fn() → vi.fn(), jest.spyOn() → vi.spyOn() - Convert vscode module mock from CommonJS to ESM - Add vitest.config.ts and tsconfig.test.json - Create vitest.d.ts for global type declarations (vi, describe, it, etc.) - Update package.json scripts and launch.json debug configuration - Remove Jest references from docs (CLAUDE.md, .vscodeignore, etc.)
1 parent f95385c commit 13412ba

32 files changed

Lines changed: 1040 additions & 2564 deletions

.gemini/styleguide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ _Function placement in functional files:_
154154

155155
**Recommended libraries**
156156

157-
- Testing: Jest, Playwright
157+
- Testing: Vitest, Playwright
158158
- Utility: es-toolkit, dayjs
159159
- HTTP: ky, @tanstack/query, @apollo/client
160160
- Form: React Hook Form
@@ -229,15 +229,15 @@ Allow multiple related assertions in one test, but separate tests when verifying
229229

230230
### Test Framework
231231

232-
Use Jest. Maintain consistency within project.
232+
Use Vitest. Maintain consistency within project.
233233

234234
### Structuring
235235

236236
Group methods/features with `describe`, write individual cases with `it`. Can classify scenarios with nested `describe`.
237237

238238
### Mocking
239239

240-
Utilize Jest's `jest.mock()`, `jest.spyOn()`. Mock external modules at top level, use `mockReturnValue`, `mockImplementation` for per-test behavior changes.
240+
Utilize Vitest's `vi.mock()`, `vi.spyOn()`. Mock external modules at top level, use `mockReturnValue`, `mockImplementation` for per-test behavior changes.
241241

242242
### Async Tests
243243

.vscode/launch.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"name": "Extension Tests",
2222
"type": "node",
2323
"request": "launch",
24-
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
25-
"cwd": "${workspaceFolder}",
26-
"args": ["--runInBand", "--config", "src/extension/jest.config.cjs"],
24+
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
25+
"cwd": "${workspaceFolder}/src/extension",
26+
"args": ["run"],
2727
"console": "integratedTerminal"
2828
}
2929
]

.vscodeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ src/global.d.ts
1212

1313
# Extension development files
1414
src/extension/tsconfig.json
15-
src/extension/jest.config.cjs
15+
src/extension/vitest.config.ts
1616
src/extension/.gitignore
1717
src/extension/.npmrc
1818
src/extension/pnpm-lock.yaml

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Quick Command Buttons is a VS Code extension that adds customizable command butt
5555
cd src/extension
5656
npm run compile # Compile TypeScript
5757
npm run lint # Run ESLint
58-
npm run test # Run Jest tests
58+
npm run test # Run Vitest tests
5959
npm run test:watch # Run tests in watch mode
6060
npm run test:coverage # Generate coverage report
6161
npm run test:ci # CI test mode
@@ -169,7 +169,7 @@ React-based configuration UI with:
169169
## Testing Strategy
170170

171171
- **Unit tests**: All manager/provider classes have `.spec.ts` files (co-located)
172-
- **Test framework**: Jest with TypeScript support
172+
- **Test framework**: Vitest with TypeScript support
173173
- **Mocking**: VS Code API mocked via `adapters` layer
174174
- **Coverage**: Use `test:coverage` for reports
175175

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,24 +365,23 @@
365365
"test": "turbo run test --filter=quick-command-buttons-extension",
366366
"test:ci": "turbo run test:ci --filter=quick-command-buttons-extension",
367367
"test:coverage": "turbo run test:coverage --filter=quick-command-buttons-extension",
368-
"test:watch": "cd src/extension && jest --watch",
368+
"test:watch": "cd src/extension && vitest",
369369
"test:e2e-ui": "cd src/view && pnpm test:e2e-ui",
370370
"test:e2e-ui:report": "cd src/view && pnpm test:e2e-ui:report",
371371
"vsce-publish": "vsce publish --no-dependencies"
372372
},
373373
"devDependencies": {
374374
"@eslint/js": "9.17.0",
375-
"@jest/globals": "30.1.2",
376375
"@semantic-release/changelog": "6.0.3",
377376
"@semantic-release/commit-analyzer": "13.0.0",
378377
"@semantic-release/exec": "7.1.0",
379378
"@semantic-release/git": "10.0.1",
380379
"@semantic-release/github": "11.0.1",
381380
"@semantic-release/npm": "13.1.2",
382381
"@semantic-release/release-notes-generator": "14.1.0",
383-
"@types/jest": "30.0.0",
384382
"@types/node": "24.3.0",
385383
"@types/vscode": "1.90.0",
384+
"@vitest/coverage-v8": "4.0.15",
386385
"@vscode/vsce": "3.7.1",
387386
"conventional-changelog-conventionalcommits": "9.1.0",
388387
"esbuild": "0.27.0",
@@ -391,15 +390,14 @@
391390
"eslint-plugin-perfectionist": "4.15.1",
392391
"globals": "16.5.0",
393392
"husky": "9.1.7",
394-
"jest": "30.1.3",
395393
"lint-staged": "16.2.7",
396394
"ovsx": "0.10.7",
397395
"prettier": "3.6.2",
398396
"semantic-release": "25.0.2",
399-
"ts-jest": "29.4.1",
400397
"turbo": "2.6.1",
401398
"typescript": "5.8.3",
402-
"typescript-eslint": "8.46.0"
399+
"typescript-eslint": "8.46.0",
400+
"vitest": "4.0.15"
403401
},
404402
"dependencies": {
405403
"es-toolkit": "1.42.0",

0 commit comments

Comments
 (0)