End-to-end and component testing · senior
Real-browser component tests and contract tests
Component tests render one component in a real browser (Vitest Browser Mode, Playwright or Cypress component testing, Storybook interaction tests) to check real layout, focus and CSS, and contract tests check that frontend and API agree on request and response shapes without running the whole system.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- jsdom cannot test layout, scrolling, real focus order, CSS visibility or IntersectionObserver; real-browser component tests can, at near-unit speed.
- Options: Vitest Browser Mode (stable since Vitest 4), Playwright component testing, Cypress component testing, Storybook stories with play functions + the Vitest addon. Stories double as test cases and documentation.
- Contract testing: consumer-driven contracts (Pact): the frontend's tests produce a contract of the requests it makes and the responses it needs; the provider verifies it in its CI, so breaking API changes fail before deploy.
- Lighter options: generate types and clients from OpenAPI/GraphQL schemas, and validate responses at runtime with zod at the boundary.
- Use contract tests where teams deploy independently (microservices, BFF); a shared TS monorepo with tRPC gets much of this from the type checker.
The red pen
Common traps: mistake → fix
Mistake: "jsdom tests cover CSS bugs"
Fix: jsdom has no layout; test those in a real browser.
Mistake: "E2E tests replace contract tests"
Fix: E2E needs every service deployed together; contracts give fast, local feedback per team.
Easy to hard
Questions interviewers ask, easy to hard
- What is component testing and how is it different from RTL in jsdom?
- What is a contract test? Who writes it and who runs it?
- How do you stop backend changes from silently breaking the web app?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.