How do you decide what to cover with unit tests versus integration tests versus end-to-end tests in a frontend app, and how do you keep the suite from becoming slow and flaky?

technical-conceptual · Mid level · software-engineering

What the interviewer is really asking

Assesses a deliberate frontend testing strategy — the right test at the right level, with attention to confidence vs. speed and flakiness.

What to say

What to avoid

Example answers

Strong: I aim for lots of fast unit tests on logic and hooks, a meaty middle of component/integration tests that render the component and assert on what the user sees, and a thin set of E2E tests over the few journeys we can't afford to break, like checkout. I test behavior over implementation — query by role and simulate clicks — so refactors don't cause false failures. For flakiness I wait on conditions instead of arbitrary timeouts, reset shared state between tests, and stub the network deterministically.

Weak: I write a test for every function and try to hit 100% coverage. For the important stuff I use end-to-end tests with the real browser because that's closest to how users actually use it, and if a test is flaky I just re-run it in CI until it passes.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.