← All topics

Testing Interview Questions and Answers

Jest and Vitest, React Testing Library, mocks and MSW, Playwright and Cypress, the test pyramid: what, how and at which level to test.

228 questions for Testing interviews with answers and explanations - Junior, Middle and Senior levels. Sample questions, online quizzes and coding tasks.

Questions by level

Sample questions

A few questions from each level with the correct answer and an explanation.

Testing · Junior

  1. What is the main goal of automated tests?

    Correct answer: To give confidence that the code works and keeps working after changes

    Tests can show the presence of bugs, not their absence. Their value is fast feedback and safe refactoring: if behaviour breaks, a test fails before users notice.

  2. What does a unit test check?

    Correct answer: A small isolated piece of code - a function, a hook or a component - on its own

    Unit tests are fast and pinpoint the failing place. Their limit: they don't show whether the pieces work together.

  3. What does an integration test check?

    Correct answer: That several units work correctly together, e.g. a form with validation and an API call

    In frontend, an integration test usually renders a feature (several components, state, router) and mocks only the network boundary.

  4. What is an end-to-end (E2E) test?

    Correct answer: A test that drives the real app in a browser the way a user would, through UI, API and database

    E2E tests give the most confidence but are slower and more fragile. Typical tools: Playwright and Cypress.

All 78 questions with answers →

Testing · Middle

  1. What is the difference between findBy… and waitFor?

    Correct answer: findBy waits for one element to appear; waitFor retries any callback until it stops throwing

    findByRole(...) is literally waitFor(() => getByRole(...)). Use findBy to wait for an element and waitFor for other assertions.

  2. How do you wait for a loading spinner to disappear?

    Correct answer: await waitForElementToBeRemoved(() => screen.queryByRole("progressbar"))

    The helper requires the element to be present at the start, then waits until the query returns null.

  3. What does the warning “An update to Component inside a test was not wrapped in act(...)” usually mean?

    Correct answer: State changed after the test stopped waiting - e.g. a request resolved after the last assertion

    RTL already wraps render and events in act. The fix is usually to wait for the final UI state with findBy/waitFor, not to add act manually.

  4. How do you test a debounced search input?

    Correct answer: Use fake timers, type, advance time by the debounce delay and check the request/result

    Fake timers make the test fast and deterministic. Real waits slow the suite and still race.

All 75 questions with answers →

Testing · Senior

  1. How do you decide where to place a test in the pyramid/trophy?

    Correct answer: At the lowest level that can still catch the failure you care about with enough confidence

    If a bug can be caught by a unit or integration test, a duplicate E2E test only adds cost. E2E is for what lower levels can't see: real wiring, deployment, third-party integrations.

  2. Why does Google's “Just Say No to More End-to-End Tests” argue against relying on E2E?

    Correct answer: E2E failures are slow to arrive, hard to isolate and often flaky, so the feedback loop is weak

    Good tests are fast, reliable and isolate failures. A suite of mostly E2E tests fails on all three.

  3. What is the “testing honeycomb” and where is it used?

    Correct answer: A shape for microservices: mostly integration tests of a service through its API, few implementation-detail unit tests and few integrated tests

    Spotify's model fits services whose complexity lies in interactions rather than internal logic.

  4. What are Google's “test sizes” (small, medium, large) based on?

    Correct answer: Resources a test may use: small - one process, no I/O; medium - one machine, localhost; large - anything, including remote systems

    Sizes describe constraints that make tests fast and deterministic, independent of the “unit/integration” naming debate.

All 75 questions with answers →

Combined quizzes with this topic

Questions from several topics at once - just like an interview for a specific role.

Coding tasks

Write your solution right in the browser, and tests check it instantly. Interview classics: debounce, throttle, deepClone, Promise.all, EventEmitter, an LRU cache and more.

Open tasks →