All jobs / Frontend / web developer / Testing
Frontend / web developer interview question · 0–1 years
What is the difference between a unit test, a component test and an end-to-end test on the frontend, and which do you write most of?
The strongest answer
Unit: one function in isolation. Component: render a piece of UI and use it like a user. End-to-end: the real app in a browser. Many of the first two, a few end-to-end on critical paths
Why it works
Right — each level trades speed for realism. Fast tests carry most of the load; a thin end-to-end layer proves the pieces work together.
What a good answer covers
- Each level buys different confidence.
- Unit: logic in isolation.
- Component: UI as the user sees it.
- End-to-end: few, critical paths.
Answers that fall short
- Close, but not the strongest: Unit tests are small and end-to-end tests are big; I write whichever the ticket asks for
Size is part of it; what matters is what each level can prove and how fast it tells you. - Weak: End-to-end tests cover everything the others do, so I would write only those
End-to-end tests are slow and fail for many unrelated reasons; using them for every branch makes the suite unusable. - Red flag: I test by clicking through the app before I push; automated tests are for the QA team
Manual clicks don’t protect the next change, and handing quality to another team worries every interviewer.
Who gets asked this
More Testing questions
- How do you assert a login button in React Testing Library?
- How do you test a search box that debounces input by 300 ms, in Jest or Vitest, without slowing the suite…
- A test passes when run alone and fails when the whole file runs, and the failing test changes when you…
- A Playwright or Cypress suite fails about one run in five on CI, in different places. The tests are full of…
- After a bad release, management asks you to enforce 90% code coverage on the frontend repository as a merge…
- How do you catch layout breakage before you translate into German and Hebrew?