--- description: TDD workflow, 80% coverage minimum, Vitest unit tests, and browser journey verification alwaysApply: true --- # Testing Requirements ## Minimum Test Coverage: 80% Test types: 1. **Unit tests** — pure functions, transformers, validators, stores, utilities (`*.test.ts` / `*.test.tsx`, colocated or `__tests__/`) 2. **Component tests** — Testing Library in packages that already have it (`packages/ui`, `packages/core-events`) 3. **App journeys** — browser verification of `apps/web` flows (login, index / form / detail). There is no Playwright or NestJS E2E suite in this repo. Runner: **Vitest**. Root command: `pnpm test`. Per-package: `pnpm --filter test`. Also `pnpm typecheck` and `pnpm check:all`. ## Test-Driven Development MANDATORY workflow: 1. Write test first (RED) 2. Run test — it should FAIL 3. Write minimal implementation (GREEN) 4. Run test — it should PASS 5. Refactor (IMPROVE) 6. Verify coverage (80%+) ## Troubleshooting Test Failures 1. Use **tdd-guide** agent 2. Check test isolation 3. Verify mocks are correct (`@repo/core-api` services, HTTP client — not a database) 4. Fix implementation, not tests (unless tests are wrong) ## Agent Support - **tdd-guide** — Use PROACTIVELY for new features, enforces write-tests-first - **e2e-runner** — Frontend journeys: Vitest + Testing Library, plus browser verification for `apps/web` - Skill: `.agents/skills/tdd-workflow/`