intermediate
Tests
Execute unit, integration, component, and end-to-end test layers according to risk and feedback-speed needs.
CI test strategy balances confidence and feedback speed. Unit tests catch logic regressions quickly; integration tests validate boundaries; component tests cover UI behavior; end-to-end tests protect critical user flows.
| Layer | Typical focus | |-------|---------------| | Unit | Pure logic, fast feedback | | Integration | DB, HTTP, module boundaries | | Component | UI states with Testing Library | | E2E | Critical journeys (Playwright, Cypress) |
- run: npm test -- --coverage
env:
CI: true
Good pipelines shard slow suites, retry only known flakes with limits, and use changed-file selection when safe. Blocking merges on flaky E2E destroys trust faster than skipping them would.
On interviews: test pyramid trade-offs, flake management, deterministic fixtures, changed-file selection, and which suites block merge.
Common pitfalls: flaky tests erode CI trust; too few integration tests leave mocks proving the wrong behavior; running the full E2E matrix on every typo.
The trade-off is coverage breadth versus pipeline duration and maintenance cost.
Checklist:
- Match test layer to risk.
- Make fixtures deterministic.
- Track and fix flakes quickly.
- Declare which suites are merge-blocking.