write-tests

Add unit, formatter, parser, contract, component or pgTAP tests to existing code following .claude/rules/07-testing.md. Use when coverage is missing, after a refactor, or when a spec checklist row has

SKILL.md

GitHub

Write tests

  1. Read .claude/rules/07-testing.md and docs/19-testing-qa.md §1–§3.
  2. Pick the layer:
    • packages/shared/**, features/*/logic/** → vitest/jest unit, 100% branch coverage, no mocks, today passed in.
    • formatters (money, date, speech) → table-driven with the exact Dutch string ('€ 1.234,56', '−€ 42,00' with U+2212).
    • parsers → committed synthetic fixture, never a real export.
    • zod contracts → round-trip parse + one rejection.
    • mutations → optimistic update + rollback.
    • screens → renders empty, data, error (RNTL, query by role/text).
    • tables/policies → pgTAP in supabase/tests/ (cross-tenant + personal scope).
  3. List cases as behaviours: happy path, empty, boundary, error, and every row the spec names (docs/10 §11, docs/06 §11). Period tests always cover 28/29/30/31-day months, anchor 28 in February, a DST boundary, and a kind change mid-period.
  4. Run the narrowest command (pnpm test:shared, pnpm test:mobile -- <path>, pnpm test:db). Break one assertion on purpose to prove the test can fail.
  5. No snapshots of component trees, no .only, no skipped tests.

Report: tests added, spec rows covered, coverage delta, remaining gaps (≤ 6 lines).