Testing
This page is for contributors and curious readers. It explains why we test and how coverage is scoped—not a live CI percentage board.
Why we test now
JustHold deals with money math, auth redirects, row-level security, and paths like signup and holdings. Automated tests catch regressions in those areas as the product grows, so portfolio logic and access rules stay trustworthy without relying on manual clicks alone.
Layers
| Layer | Location | Runner | Use for |
|---|---|---|---|
| Unit | tests/unit/ | Vitest | Pure helpers in lib/ — no DB or network |
| Integration | tests/integration/ | Vitest + local Supabase | RLS, RPCs, database behaviour |
| E2E | tests/e2e/ | Playwright | Critical user flows (e.g. signup, holdings gating) |
Scripts
pnpm test # unit
pnpm test:watch # unit, watch mode
pnpm test:coverage # unit + coverage thresholds (CI)
pnpm test:int # integration (local Supabase)
pnpm test:e2e # Playwright (local)
Coverage philosophy
Unit coverage thresholds in vitest.config.ts apply only to a curated list of pure modules (formatters, money helpers, sort keys, and similar). We keep that list small on purpose so the number stays meaningful.
- Inside the include list — aim for solid unit coverage; CI enforces thresholds (e.g. ~80% lines on that set).
- Outside the include list — not “forgotten.” RSC pages, server actions, and DB behaviour are covered (or planned) by integration and e2e suites instead of unit thresholds.
When a pure lib/ module is fully tested, add its path to coverage.include so thresholds stay honest.
Known gaps (by category)
We do not publish a file-by-file gap list here—it goes stale. Broadly, these areas are thin or absent at the unit layer today:
- Most UI and RSC page surfaces
- Admin CMS and content tooling
- The docs shell itself
- Behaviour that needs a real database or browser (prefer integration / e2e)
Pull requests that harden pure domain helpers and then extend coverage.include are welcome.
Day-to-day authoring rules live in the repo skill .cursor/skills/justhold-testing/SKILL.md (also mirrored under agent skills). Prefer that over duplicating every convention here.