v3/implementation/adrs/ADR-008-VITEST.md
Status: Implemented Date: 2026-01-03
v2 uses Jest for testing. Vitest is a modern alternative that's faster and has better ESM support.
Migrate to Vitest for v3.
Vitest Advantages:
Migration:
// package.json
{
"devDependencies": {
"vitest": "^1.0.0",
"vite": "^5.0.0"
},
"scripts": {
"test": "vitest",
"test:ui": "vitest --ui"
}
}
Configuration:
// vitest.config.ts
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['**/*.test.ts', '**/*.spec.ts'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: ['node_modules', 'dist'],
},
testTimeout: 10000,
hookTimeout: 10000,
},
});
Test Migration:
// Before (Jest)
describe('Agent', () => {
beforeEach(() => {
jest.resetAllMocks();
});
it('should spawn', async () => {
const mock = jest.fn();
// ...
});
});
// After (Vitest - compatible API)
import { describe, it, beforeEach, vi } from 'vitest';
describe('Agent', () => {
beforeEach(() => {
vi.resetAllMocks();
});
it('should spawn', async () => {
const mock = vi.fn();
// ...
});
});
| Metric | Jest | Vitest | Improvement |
|---|---|---|---|
| Test execution | ~30s | ~3s | 10x faster |
| Watch mode startup | ~5s | ~1s | 5x faster |
| ESM support | Partial | Native | Better DX |
| HMR | No | Yes | Instant feedback |
Implementation Date: 2026-01-04 Status: ✅ Complete