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

Why is mocking at the network layer usually better than mocking a data-fetching hook?

Short interview answer

Mocking the network preserves the real hook's logic — loading states, error handling, caching — under test, and it exercises the same code path production traffic uses, so a bug in the hook itself would still be caught.

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