--- description: TDD workflow, 80% coverage minimum, Vitest unit tests, and Playwright E2E for apps/web 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** — Playwright E2E in `apps/web/e2e/` (login is the first sample). Mock the backend with `page.route`; do not hit a live API unless the user asks. There is no NestJS/Supertest suite in this frontend repo. Runner: **Vitest** for unit tests (`pnpm test`). Playwright for web E2E (`pnpm test:e2e:web` or `pnpm --filter web test:e2e`). Also `pnpm typecheck` and `pnpm check:all` (unit/lint/typecheck only). ## 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` / HTTP client for unit tests; `mockBackend` in `apps/web/e2e/fixtures/mock-api.ts` for Playwright) 4. Fix implementation, not tests (unless tests are wrong) ## Agent Support - **tdd-guide** — Use PROACTIVELY for new features, enforces write-tests-first - **e2e-runner** — Playwright E2E in `apps/web/e2e/`, plus Vitest + Testing Library for package journeys - Skill: `.agents/skills/tdd-workflow/`