Testing Strategy Guide — Unit, Integration & E2E Balance
Where to invest test effort: the 70/20/10 split, flaky-test triage, and CI gates that don't slow teams.
1. The Right Pyramid
Spend ~70% on fast unit tests for business logic, ~20% on API/integration tests for contracts, ~10% on E2E for critical user journeys. Inverted pyramids (all E2E) produce slow, flaky suites teams learn to ignore.
Every bug fix ships with a regression test that fails without the fix. This single rule compounds into a genuinely protective suite within quarters.
2. Flaky Tests Are Bugs
Quarantine flaky tests immediately — a suite the team distrusts protects nothing. Fix the timing assumption or delete the test; there is no third option.
Seed test data deterministically and freeze clocks. Nine of ten flakes come from time, randomness, or shared state.
3. CI Gates That Help
Block merges on type-check, lint, unit tests, and the smoke E2E trio (login, checkout, core flow). Full E2E runs nightly, not per-PR — speed of feedback beats completeness per commit.
Coverage thresholds guard against backsliding (fail below 70%), never chase 100% — untested lines should be deliberate, like generated code.
Frequently asked questions
Playwright or Cypress?
Playwright — faster, better parallelism, API testing in the same runner. We standardise on it for all E2E.
Who writes tests — devs or QA?
Devs write unit/integration alongside features; QA engineers own E2E journeys and exploratory testing. Shared ownership, clear lanes.