What problem does it solve?
Vitest projects often end up with flaky or misleading tests that don’t actually validate behavior, fail to prevent coverage regressions, or accidentally use the wrong mocking APIs, making refactors risky.
Core Features & Use Cases
- Correct Vitest mocking patterns: Use vi.mock() for module replacement, vi.fn() for controllable mocks, and vi.spyOn() for spying without mixing toolchains.
- Clean, deterministic async assertions: Await expect(...).rejects/resolves to ensure failures are never silently ignored.
- Safe test structure & coverage guardrails: Mirror source structure for unit tests, isolate integration tests from unit behavior, and enforce thresholds in vitest.config.ts.
- Use case: You’re refactoring a service layer and want confidence that behavior stays stable while controlling dependencies; apply the skill to set up src/tests unit tests, tests/integration for real dependencies, and coverage thresholds to block regressions.
Quick Start
Configure your test files to mirror your source under src/tests, replace dependencies with vi.mock() at the top level, and set coverage thresholds in vitest.config.ts.