Skip to content

Testing Strategy

Ankit Upadhyay edited this page Aug 25, 2026 · 3 revisions

Testing Strategy

What we test, at which layer, and the coverage bar. The gate that enforces it is Code Quality Gates.

The pyramid

Layer Tool Where Runs
Unit / component Jest (+ React Testing Library on web) every workspace every PR (affected workspaces)
Web E2E Playwright apps/frontend/e2e frontend-path PRs (public smoke + a11y); the credentialed auth suite runs only on manual dispatch behind the e2e environment — see #1869
Desktop E2E Playwright (Electron) apps/desktop/tests/e2e PRs and pushes to main/dev (desktop-e2e.yml)
Mobile E2E Detox apps/mobileAppYC/e2e manual / local only (not wired into CI)
Accessibility jest-axe / axe-core apps/frontend every frontend PR
Visual regression Chromatic (Storybook) components on component change

Recommended CI order: unit first (fast feedback), then the public web E2E jobs on frontend PRs; mobile E2E stays a manual/local pass for now.

Coverage mandate

  • New code = new tests. Any new file must reach ≥ 90% statements / branches / functions on first commit — no new file ships without tests.
  • Frontend is stricter: target ≥ 95% statements/branches/functions/lines across apps/frontend; any file you touch must end at equal-or-higher coverage than you found it.
  • Coverage is reported to SonarCloud; the quality gate reads new-code coverage.

What to write for what you add

You add Required test
Service function / API call Jest unit: success + all error branches
Zustand store / Redux slice Jest: every action, selector, edge case
Custom hook renderHook covering all returns and branches
Utility / lib function Jest unit with full branch coverage
UI component (web) RTL render + at least one interaction test
Screen (mobile) Jest + Testing Library render test
E2E-critical flow Playwright (web) or Detox (mobile)

Running tests

# Targeted (preferred during development) - never the full suite by default
# Note the plural flag: Jest 30 (both apps) renamed --testPathPattern to
# --testPathPatterns; the singular form now errors.
pnpm --filter frontend run test -- --testPathPatterns="Availability"
pnpm --filter mobileAppYC run test -- --testPathPatterns="<YourFile>"

# Web E2E
pnpm --filter frontend e2e            # headless; also e2e:headed / e2e:ui
# first time: cd apps/frontend && pnpm exec playwright install

# Mobile E2E
pnpm --filter mobileAppYC e2e:build:ios && pnpm --filter mobileAppYC e2e:ios

Full E2E setup (config/spec locations, how the Playwright and Detox harnesses launch): docs/e2e-testing.md.

Accessibility testing

Every new web component ships a jest-axe assertion (expect(results).toHaveNoViolations()), enforced as part of the frontend Jest suite in the single-run CI pipeline (ci.yaml's test stage — the former frontend-a11y workflow was folded in by PR #1939). Manual regression checks that tooling can't automate (200% zoom, reflow, reduced motion) are in the Accessibility checklists.

Gotchas

  • Mocking @yosemite-crew/types: spread jest.requireActual('@yosemite-crew/types') or forms.ts fails to load.
  • Mobile suite isolation: raw react-test-renderer trees must be drained/unmounted or a random test can flake per full parallel run (root cause of #1822).
  • The type-check (npx tsc --noemit) step can take 60-120s — budget for it.

Related

Product & Domain
Architecture
Applications
Design & Accessibility
Engineering Handbook
Decisions (ADRs)
Design Docs & Plans
Roadmap
Operations
Meta

Canonical code & docs: main repo · Auto-generated companion: DeepWiki

Clone this wiki locally