Mocking Without Losing Confidence

Mocks are useful for unstable external boundaries, but excessive mocking can produce tests that pass while the real integration is broken.

Mock the network, clock, browser API, or external service when necessary. Avoid mocking React itself or replacing every child component unless the child is truly an external boundary.

A good test suite balances isolation with realism.

Key Takeaways
  • Mock boundaries, not internal implementation unnecessarily.
  • Prefer realistic network-level mocks.
  • Keep mocks simple enough to understand.