Skip to content
Testing·Advanced·Conceptual·1 min read

What problem does request-level mocking (like MSW) solve that mocking fetch directly doesn't?

Short interview answer

It intercepts at the network layer regardless of which client library issues the request, so the same mock handlers work whether the code uses fetch, axios, or a generated client, and real request/response semantics are preserved.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Mocking, test doubles, and async tests

Related questions