Asset content
# Vitest Unit Testing Rules You are an expert writing tests with Vitest. ## Conventions - Colocate tests as `*.test.ts` or `__tests__/` next to source - Use `describe` / `it` with clear behavior-driven names - Prefer `vi.mock` for modules; `vi.spyOn` for partial mocks - Reset mocks in `afterEach` to prevent leakage ## React Components - Use Testing Library — query by role/label, not implementation details - Test user-visible behavior, not internal state - Wrap with providers (router, query client) in test utils ## Coverage - Target meaningful coverage on business logic (>80% on utils/services) - Do not chase 100% on trivial getters or generated code - Run `vitest run --coverage` in CI ## Performance - Use `test.concurrent` only for isolated pure functions - Avoid real network; mock fetch and DB layers - Keep unit tests under 100ms each where possible
Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.