Skip to content

Vitest — Checklist

OWNER: marije, judith ALSO_USED_BY: antje LAST_VERIFIED: 2026-03-26 GE_STACK_VERSION: vitest ^4.0.18


PROJECT SETUP CHECKLIST

  • [ ] CHECK: vitest.config.ts exists with correct path aliases matching tsconfig.json
  • [ ] CHECK: tests/setup.ts exists with vi.restoreAllMocks() in afterEach
  • [ ] CHECK: tests/setup.ts calls cleanup() from @testing-library/react
  • [ ] CHECK: @testing-library/jest-dom/vitest imported in setup for DOM matchers
  • [ ] CHECK: Coverage provider set to v8 with @vitest/coverage-v8 installed
  • [ ] CHECK: Coverage thresholds configured (statements 80, branches 75, functions 80, lines 80)
  • [ ] CHECK: coverage.include explicitly lists source directories
  • [ ] CHECK: JSDOM browser API mocks present in setup (IntersectionObserver, ResizeObserver, matchMedia)

TEST WRITING CHECKLIST

  • [ ] CHECK: Test file named {module}.test.ts or {module}.test.tsx
  • [ ] CHECK: Uses it (not test) for individual cases
  • [ ] CHECK: Test names read as sentences describing expected outcome
  • [ ] CHECK: Every it block has at least one meaningful assertion
  • [ ] CHECK: Async tests use async/await (not .then())
  • [ ] CHECK: Error cases use rejects.toThrow() (not try/catch)
  • [ ] CHECK: Parameterized tests use it.each when 3+ cases share structure
  • [ ] CHECK: No hardcoded test data — use fixtures from tests/fixtures/ IF_SKIPPED: Test data drifts across files, becomes inconsistent

MOCKING CHECKLIST

  • [ ] CHECK: vi.mock calls provide explicit factory functions (no auto-mock)
  • [ ] CHECK: Variables needed in mock factories use vi.hoisted()
  • [ ] CHECK: Spies created inside individual tests (not at describe level) IF_SKIPPED: Spy restoration between tests silently kills return values
  • [ ] CHECK: Fake timers paired with vi.useRealTimers() in afterEach
  • [ ] CHECK: No mocking of internal module calls — refactor or use DI instead

COVERAGE CHECKLIST

  • [ ] CHECK: Coverage runs in CI on every PR
  • [ ] CHECK: Threshold failure blocks merge
  • [ ] CHECK: No files excluded just to meet thresholds
  • [ ] CHECK: Tests assert behavior, not implementation (no gaming)

VITEST V4 MIGRATION CHECKLIST

  • [ ] CHECK: poolOptions moved to top-level config
  • [ ] CHECK: coverage.all removed — coverage.include set explicitly
  • [ ] CHECK: VITEST_MAX_THREADS/VITEST_MAX_FORKS replaced with VITEST_MAX_WORKERS ADDED_FROM: vitest-v4-migration-2026-03, breaking change

Cross-References

READ_ALSO: wiki/docs/stack/vitest/index.md READ_ALSO: wiki/docs/stack/vitest/pitfalls.md READ_ALSO: wiki/docs/stack/playwright/checklist.md