All jobs / Full-stack developer / Testing

Full-stack developer interview question · 1–3 years

How do you keep the real API out of a component test without the test drifting from the real thing?

The strongest answer

Intercept at the network boundary — a request mock such as MSW returns realistic responses, the component runs its own fetching code, and the same handlers cover empty and error responses

Why it works

Right — mocking the network keeps the component’s real data layer under test, and one set of handlers covers success, empty and failure.

What a good answer covers

Answers that fall short

Who gets asked this

More Testing questions