Phase 12Days 125-129

Testing: Vitest & Backend Testing

Unit, integration, and component tests that actually catch bugs — with CI coverage

Phase Goal

Write tests a team would respect: fast unit tests with Vitest, real API/integration tests against a test database, and component tests with React Testing Library — wired into CI. (Browser E2E/Playwright is deliberately out of scope.)

Progress

Day 125: Why Test + Vitest Fundamentals

Day 126: Mocking, Spies & Test Doubles

Day 127: Backend / API Testing

Day 128: Integration Testing Real Flows

Day 129: Project — Permit Appeal Regression Lab

Capstone
Permit Appeal Regression Lab — TESTED

Build a deliberately small permit-appeal flow with a deadline/time-zone bug and an authorization leak. Define its contract, reproduce both failures, and protect the corrected workflow with unit, API integration, component, and end-to-end tests plus honest CI coverage thresholds.

  • A written failure scenario and expected behavior before the first test.
  • Vitest unit tests, Supertest integration tests, RTL behavior tests, and one Playwright critical path.
  • CI reports coverage honestly and blocks the known regression.

Phase Complete!

After this phase, you'll be able to:

  • Vitest: structure, matchers, setup/teardown, coverage
  • Test doubles: spies, module mocks, fake timers — without over-mocking
  • API/integration tests with Supertest + an isolated memory database
  • Fixtures/factories and deterministic, non-flaky tests
  • Component tests with React Testing Library and user-event
  • A single CI-ready test command with a coverage threshold

You can add a trustworthy test suite to any codebase — the difference between "it works on my machine" and code a team will merge.