Part II β The Shield Β· Lesson 4.1
Testing Overview
In one lineBuy the most confidence per second of CI time β that ratio decides the shape of your suite.
Where you've seen itA 40-minute pipeline that everyone learns to ignore. A suite nobody waits for provides zero protection, however thorough it is.
Diagram
THE PYRAMID β and what each layer actually buys
β² confidence per test
β
ββββββββββββ΄βββββββββββ
β E2E β 10sβ2min each Β· real browser
β (5β10%) β proves the FLOW works
βββββββββββββββββββββββ€
β Integration β 50β500ms each Β· components wired
β (20β30%) β proves the PIECES fit
βββββββββββββββββββββββ€
β Unit β <10ms each Β· pure functions
β (60β70%) β proves the LOGIC is right
βββββββββββββββββββββββ
β
βΌ cost, flakiness, time to debugTHE ICE-CREAM CONE β the failure mode to name in an interview
βββββββββββββββββββββββ
β E2E β 200 slow, flaky browser tests
ββββββββββββ¬βββββββββββ€
β Integr. β few
ββββββ¬ββββββ
β Unit almost none
Symptoms: 40-min CI, "just re-run it", nobody trusts red builds.WHAT EACH LAYER CANNOT SEE
unit β wiring bugs, wrong props, bad API contract
integration β routing, auth, real network, browser quirks
E2E β edge-case logic (too slow to enumerate there)
all three β visual regressions, a11y, performance budgetsHow it works
- Push detail down. Every edge case belongs in the fastest layer that can express it.
- Push confidence up. A handful of E2E tests cover the money paths β signup, checkout, the one flow that must never break.
- Test behaviour, not implementation. A test that breaks on refactor is a maintenance cost, not a safety net.
- Budget CI time explicitly. Under 10 minutes to merge is the target; past that, developers route around the suite.
- Quarantine flaky tests immediately. One test that fails randomly teaches the team to ignore all red builds.
Trade-offs
| More unit tests | More E2E tests |
|---|---|
| Fast, cheap, precise failures | Slow, expensive, vague failures |
| Miss integration and wiring bugs | Catch what users actually hit |
| Refactor-fragile if over-mocked | Refactor-resilient |
Interview angle
"What's your testing strategy for a large frontend?"
- Name the shape and the ratio, then justify it by CI time and debugging cost, not by dogma.
- Cover money paths with E2E, everything else lower; add visual and a11y checks as separate gates.
- State the flake policy β quarantine within a day β because that's what keeps a suite trusted.
Recap
- Optimise for confidence per second of CI, not for coverage percentage.
- Push detail down the pyramid, confidence up.
- An ignored suite and no suite protect you equally.