Migrate full test suite from Jest to Vitest#54
Conversation
|
@copilot resolve the merge conflicts in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
+ Coverage 98.30% 98.51% +0.20%
==========================================
Files 12 12
Lines 1064 1011 -53
Branches 260 270 +10
==========================================
- Hits 1046 996 -50
+ Misses 18 15 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ions + vitest additions
Done in d14a555. The conflict was in |
|
@copilot now run tests and provide benchmarking. should we migrate? |
Both suites pass cleanly. Here are the benchmarking results: Benchmark resultsAll timings are wall-clock (3 runs each, first run excluded as JIT warm-up).
Extrapolated full suite in Vitest: ~1.5–2.0s wall (rough estimate based on per-file scale — Vitest runs files in parallel threads so it doesn't scale linearly). Migration delta (per file)Pure-logic files (like Mock-heavy files (like
12 test files × ~10–15 touch-points each = ~120–180 mechanical changes, no logic changes needed. Recommendation: Yes, migrateReasons in favour:
The only cost is the one-time migration of ~12 files (~2–3 hours of mechanical work). |
@copilot provide full migration, run full suites at the end and provide report how faster is it |
Agent-Logs-Url: https://github.com/dnim/doro-cli/sessions/33d179fa-6e8e-46ca-8b6d-467c14b50cba Co-authored-by: dnim <1839962+dnim@users.noreply.github.com>
Full migration done in 91179ce. Here's the final report: Full Suite ResultsAll 193 tests pass (1 skipped — same as Jest baseline), lint clean, TypeScript clean. Benchmark
The test-only delta is the most telling: 330ms vs 1s for the same 194 tests. The remaining gap is transform+import time (Vitest's vite pipeline). What changed
|
|
@copilot resolve the merge conflicts in this pull request |
…t-vs-vitest # Conflicts: # package-lock.json
Done in 8d5906e. The conflict was in |
|
@copilot Codecov / codecov/project 98.22% (-0.09%) compared to 824f135 Details Additional details and impacted files 🚀 New features to boost your workflow: |
…re for getCurrentVersion fallback Agent-Logs-Url: https://github.com/dnim/doro-cli/sessions/aad1a6d2-2a37-4de8-8ae3-082ea8a220f8
Fixed in c697e18. The -0.09% came from two uncovered lines in
|
Completes the Jest → Vitest migration for the entire test suite. Vitest replaces Jest as the sole test runner; all 12 test files are ported, Jest and ts-jest are removed, and the full suite runs ~28% faster wall-clock (~3× faster test-only execution).
What changed
Test files (all 12 migrated)
jest.mock()→vi.mock()hoisted to module top (Vitest requirement)jest.fn()/jest.spyOn()/jest.clearAllMocks()→vi.*equivalentsenv-paths,node:fs) get explicitdefault:key in factory(x as jest.Mock).mockReturnValue(...)→vi.mocked(x).mockReturnValue(...)(type-safe, no cast)Production code
src/update.ts: replaced runtimerequire('child_process')inside a function body with a top-levelimport { spawn } from 'node:child_process'— required for Vitest's ESM mock interceptor to work, and removes an existingeslint-disablecommentInfrastructure
jest.config.cjsdeleted;src/__tests__/vitest/spike directory deleted (merged into main suite)package.json:test:unitnow runs Vitest;ts-jest,@types/jest,babel-jestremoved as dependenciesvitest.config.ts: include pattern broadened from spike-only tosrc/__tests__/**eslint.config.mjs:globals.jest→globals.node(correct for a Node CLI tool)Benchmark
--runInBand(serial)Migration delta (per file pattern)
Pure-logic files (like
constants.test.ts): 1-line change —@jest/globals→vitest.Mock-heavy files (like
config.test.ts):Notable: Vitest's ESM mock factory requires an explicit
defaultkey for CJS-wrapped modules;vi.mocked()enforces the function type wherejest.Mockcast did not.