Skip to content

ADR-007: Vitest as Test Runner

Date: 2026-02-27 Authors: Jean-Francois Meyers Scope: granit-front

The monorepo needs a unit test framework capable of:

  • Executing TypeScript tests without prior transpilation
  • Supporting ESM ("type": "module" in package.json)
  • Offering a performant watch mode for development
  • Generating coverage reports (lcov, html)
  • Working in a pnpm multi-package workspace

Use Vitest (v4) as the test framework for all packages in the monorepo:

Terminal window
pnpm test # watch mode (development)
pnpm test:coverage # v8 coverage (CI)

Tests are co-located with source code:

  • src/**/*.test.ts for simple unit tests
  • src/__tests__/ for more complex test suites

The minimum coverage target is 80% on all new code.

  • Advantage: uses the same transformation pipeline as Vite (esbuild), native ESM and TypeScript support, Jest-compatible API, fast file-system-based watch mode
  • Disadvantage: younger ecosystem than Jest, some Jest plugins have no Vitest equivalent
  • Advantage: industry standard, extensive plugin ecosystem
  • Disadvantage: experimental and unstable ESM support, TypeScript configuration requires ts-jest or @swc/jest, slow watch mode on large workspaces
  • Advantage: zero dependency, ships with Node.js
  • Disadvantage: limited API, no watch mode, no coverage integration, no mocking framework
CriterionVitestJestNode.js test runner
TypeScript transpilationesbuild (automatic)ts-jest / @swc/jestManual
ESM supportNativeExperimentalNative
Watch modeFile-system-based (fast)Polling (slow)None
API compatibilityJest-compatibleStandardLimited
Coveragev8 (built-in)istanbul / v8Experimental
Workspace-awarevitest.workspace.tsCustom configNo
  • Zero transpilation configuration: Vitest uses esbuild, same as Vite — .ts files are transpiled on-the-fly
  • Native ESM: no issues with import/export, import.meta, etc.
  • Performance: parallel execution, file-system-based watch mode (no polling)
  • Jest-compatible API: describe, it, expect, vi.fn() — minimal learning curve for developers coming from Jest
  • v8 coverage: lcov and html reports without additional dependencies
  • Workspace-aware: vitest.workspace.ts for multi-package configuration
  • Ecosystem: some Jest plugins have no Vitest equivalent (marginal risk)
  • Maturity: Vitest is more recent than Jest (mitigated by massive adoption in the Vite ecosystem)

This decision should be re-evaluated if:

  • Jest achieves stable ESM support with comparable performance
  • Vitest development slows or the project is abandoned
  • A new test runner emerges with compelling advantages