A test pyramid that catches regressions in minutes: lots of fast unit tests, focused integration tests, and a handful of E2E flows.
Recommended stack
- Vitest - unit/integration. Vite-speed tests with first-class TS and watch mode you'll actually use.
- Playwright - E2E. Reliable cross-browser flows with traces that make failures debuggable.
- GitHub Actions - CI gate. No green, no merge - the suite only matters if it blocks.
- Testing Library - component tests. Tests that interact like users survive refactors.
Build steps
- Unit-test pure logic exhaustively (parsers, calculators, reducers) - milliseconds each.
- Integration-test each API route against a real (containerized) database, not mocks of your own DB.
- Choose 3–5 E2E journeys that map to revenue (signup, core action, checkout); nothing else.
- Make tests deterministic: fake timers, seeded data, no network to third parties.
- Quarantine flaky tests same-day with an issue; a flaky suite is an ignored suite.
Watch out for
- Mocking the database in integration tests - you're testing your mocks.
- E2E for every edge case; pyramid inverts and CI takes 40 minutes.
- Snapshot tests as assertions of convenience that nobody reads on failure.
Definition of done
- Unit+integration suite < 2 minutes locally
- A broken core flow fails CI before review
- Zero
skipped tests older than a week