What problem does it solve?
Teams struggle to keep tests fast, reliable, and well-scoped across unit, integration, and end-to-end levels; this guidance codifies patterns to reduce flakiness, speed feedback loops, and ensure meaningful coverage for Node.js/TypeScript applications using Vitest.
Core Features & Use Cases
- Test Pyramid Guidance: Clear distinctions between unit, integration, and E2E tests with recommendations on count, speed, and dependencies.
- Unit Test Conventions: Colocated *.test.ts files, pure-function focus, and helper utilities to build concise, deterministic tests.
- Integration Test Patterns: Test DB lifecycle, fixtures, truncation between tests, and serial execution recommendations for shared resources.
- Mocking Strategy: When to mock I/O boundaries, how to use vi.mock and fake timers, and guidance to avoid over-mocking.
- Vitest Configuration & Coverage: Sample vitest configs, separate integration config, and coverage thresholds to enforce quality.
- Flaky Test Mitigation: Checklist for race conditions, time dependencies, shared state, and randomization fixes.
Quick Start
Run unit tests with Vitest and run integration tests using the vitest.integration.config.ts while starting the test database fixtures defined in tests/integration/setup.ts.