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.tsexists with correct path aliases matchingtsconfig.json - [ ] CHECK:
tests/setup.tsexists withvi.restoreAllMocks()inafterEach - [ ] CHECK:
tests/setup.tscallscleanup()from@testing-library/react - [ ] CHECK:
@testing-library/jest-dom/vitestimported in setup for DOM matchers - [ ] CHECK: Coverage provider set to
v8with@vitest/coverage-v8installed - [ ] CHECK: Coverage thresholds configured (statements 80, branches 75, functions 80, lines 80)
- [ ] CHECK:
coverage.includeexplicitly lists source directories - [ ] CHECK: JSDOM browser API mocks present in setup (IntersectionObserver, ResizeObserver, matchMedia)
TEST WRITING CHECKLIST¶
- [ ] CHECK: Test file named
{module}.test.tsor{module}.test.tsx - [ ] CHECK: Uses
it(nottest) for individual cases - [ ] CHECK: Test names read as sentences describing expected outcome
- [ ] CHECK: Every
itblock 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.eachwhen 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.mockcalls 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()inafterEach - [ ] 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:
poolOptionsmoved to top-level config - [ ] CHECK:
coverage.allremoved —coverage.includeset explicitly - [ ] CHECK:
VITEST_MAX_THREADS/VITEST_MAX_FORKSreplaced withVITEST_MAX_WORKERSADDED_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