What does "mocking" mean in E2E tests?
Mocking in E2E tests is substituting real external requests and responses (usually network ones) with pre-prepared fake data, so the test runs predictably and stably.
Why it is used
- eliminate dependency on the real backend, network and delays
- reproduce the same behavior on every run
- test scenarios that are hard or slow to get from the real API (errors, special states, etc.)
What this looks like, essentially
- the test sends a request → a fake response is substituted instead of the real server
- the UI receives the data and behaves as if it were interacting with the real system
What is mocked most often
fetch/XHR- API responses (JSON)
- server errors
- delays and statuses (200, 400, 500, timeout)
The key idea: a mock does not test the real backend, it captures the frontend's behavior under controlled conditions.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.