Testing interview question · Most asked

Your end-to-end test suite is flaky and takes an hour. How do you fix it?

Scenario Asked in Backend Engineer · QA Engineer / SDET · Frontend Engineer · Full Stack Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Measure first: which tests fail intermittently and which are slow. Quarantine flaky tests so they don't block merges, fix the root causes (timing waits, shared test data, order dependence, unstable environments), push coverage down to faster API and component tests where possible, and run the remaining end-to-end tests in parallel shards.

Longer Answer

  • Flakiness causes: fixed sleeps instead of waiting for conditions, tests sharing accounts or data, reliance on test order, animations, third-party services, timezone and clock issues, under-resourced environments.
  • Fixes: explicit waits for state (Playwright auto-waiting, expect(...).toBeVisible()), unique data per test created through APIs, mocking external services, stable selectors (data-testid, roles).
  • Speed: delete duplicated end-to-end coverage, test business rules at the API level, set up state through APIs not the UI, shard across machines, run only tests affected by the change on pull requests and the full suite nightly.
  • Policy: a flaky-test owner and a deadline; quarantined tests can't stay quarantined forever.

Key Points

  • Measure flakiness and duration per test.
  • Quarantine, then fix root causes.
  • Wait for conditions, never fixed sleeps.
  • Push coverage down the pyramid; shard the rest.

Explanation

What interviewers look for

Diagnosing the real causes of flakiness and restructuring the suite, not just adding retries.

More Testing questions

← All Testing questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake