Mocking an API module works, but it's incomplete because we have to make all these assertions that we're calling it properly and then we'd need to write some other tests for the API module itself to make sure that it responds properly to those calls.

In this lesson, I'll show you how you can use a package called MSW to intercept and handle those HTTP requests instead so we can get a great deal more confidence.

Get the code on GitHub


Mock HTTP Requests with MSW