Why are E2E tests often flaky?
Reasons for E2E test instability:
- Dependency on external systems: a real API, database, network, or third-party services can respond slowly, with errors, or not respond at all.
- Asynchronous interface: elements appear with a delay, and the test clicks "too early."
- Fragile selectors: tests fail because of minor changes in the markup or text.
- Flakiness from timing:
sleep, incorrect waits, differences between environments (local, CI). - Lack of data isolation: leftover junk in the database, state from previous tests, races for resources.
- CI environment: a slow container, background load, browser instability in headless mode.
Summary: E2E tests are unstable because they depend on a large number of variables that the test has almost no control over.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.