14 · Engineering craft

Testing

Unit, integration, e2e — and what to test at each layer.

Testing question bank 28 questions · 5 categories

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.

  1. What is the testing pyramid / trophy?
  2. Unit vs integration vs E2E — when do you use each?
  3. What is React Testing Library's philosophy?
  4. How do you query elements — getBy vs queryBy vs findBy?
  5. How do you mock an API in tests (MSW)?
  6. How do you test async code and hooks?
  7. What is a flaky test and how do you fix it?
  8. Playwright vs Cypress — trade-offs?
  9. What is snapshot testing and its pitfalls?
  10. How do you test accessibility (jest-axe)?
  11. What should you not test?
  12. How do you test a debounced function (fake timers)?
  13. Is 100% code coverage the goal? Why or why not?
  14. How do you test a component that fetches data?
  15. What is visual regression testing?

Related: 06-react · 11-accessibility · 16-machine-coding

Missing something? Add a row.

ESC

Type to search across every question bank.

navigate open 3,610 questions indexed