Skip to content

QuizNot attempted

What to mock

In an integration test for a checkout form, what should you mock?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • The network boundary (e.g. MSW handlers), not your own components or hooks
  • Mock the edges you don't control, here the network (MSW handlers intercept fetch), and keep your own components and hooks real so the test exercises how they integrate.
  • Not every child component: then it is no longer an integration test.
  • Not React state hooks: mocking React internals tests nothing real.
  • Not the production API: slow, flaky, and may create real orders.