14 · Engineering craft
Testing
Unit, integration, e2e — and what to test at each layer.
How you prove the thing works. Expect "how would you test this?" after any machine-coding round.
Strategy
| Topic | Difficulty | Time | Tags | Best Resources |
|---|---|---|---|---|
| The testing pyramid / trophy | 🟢 | 30m | #strategy |
Kent C. Dodds: testing trophy ⭐ |
| What to test (and what not to) | 🟡 | 45m | #strategy |
Kent C. Dodds: write tests ⭐ |
| Test-driven development | 🟡 | 45m | #tdd |
Martin Fowler: TDD ⭐ |
| Flaky tests & determinism | 🟡 | 45m | #strategy |
Playwright: retries ⭐ |
Unit & component
| Topic | Difficulty | Time | Tags | Best Resources |
|---|---|---|---|---|
| Unit testing with Jest | 🟢 | 1h | #unit #jest |
Jest ⭐ |
| Vitest | 🟢 | 45m | #unit #vitest |
Vitest ⭐ |
| React Testing Library (RTL) | 🟡 | 1.5h | #component #rtl |
Testing Library ⭐ |
| Query priorities & user-centric tests | 🟡 | 45m | #rtl #a11y |
Testing Library: queries ⭐ |
| Testing hooks | 🟡 | 45m | #rtl #hooks |
Testing Library ⭐ |
| Snapshot testing (and its traps) | 🟡 | 30m | #unit |
Jest: snapshots ⭐ |
Mocking
| Topic | Difficulty | Time | Tags | Best Resources |
|---|---|---|---|---|
| Mocking (modules, timers, functions) | 🟡 | 45m | #mocking |
Jest: mock functions ⭐ |
| Mocking network with MSW | 🟡 | 1h | #mocking #msw |
MSW ⭐ |
| Fake timers & async testing | 🟡 | 45m | #mocking #async |
Jest: timer mocks ⭐ |
Integration, E2E & specialized
| Topic | Difficulty | Time | Tags | Best Resources |
|---|---|---|---|---|
| Integration testing | 🟡 | 1h | #integration |
Kent C. Dodds ⭐ |
| E2E with Playwright | 🔴 | 1.5h | #e2e #playwright |
Playwright ⭐ |
| E2E with Cypress | 🟡 | 1h | #e2e #cypress |
Cypress ⭐ |
| Visual regression testing | 🟡 | 45m | #visual |
Playwright: snapshots ⭐ |
| Accessibility testing | 🟡 | 45m | #a11y |
jest-axe ⭐ |
| Performance testing / budgets | 🔴 | 45m | #performance |
web.dev: budgets ⭐ |
| Component testing (Storybook) | 🟡 | 45m | #component |
Storybook: testing ⭐ |
❓ Rapid-fire testing interview questions
Real testing questions asked at the SDE-2 / senior level. Answer out loud, then verify above.
- What is the testing pyramid / trophy?
- Unit vs integration vs E2E — when do you use each?
- What is React Testing Library's philosophy?
- How do you query elements —
getByvsqueryByvsfindBy? - How do you mock an API in tests (MSW)?
- How do you test async code and hooks?
- What is a flaky test and how do you fix it?
- Playwright vs Cypress — trade-offs?
- What is snapshot testing and its pitfalls?
- How do you test accessibility (jest-axe)?
- What should you not test?
- How do you test a debounced function (fake timers)?
- Is 100% code coverage the goal? Why or why not?
- How do you test a component that fetches data?
- What is visual regression testing?
Related: 06-react · 11-accessibility · 16-machine-coding
Missing something? Add a row.