How to mock fetch/HTTP requests in tests?
Answer
•For fetch, you can use MSW.
•MSW mocks at the network level (realistic).
•For unit tests, you can mock the client (axios).
•Watch out for resetting mocks between tests.
•Check loading/error states.
Was this answer helpful?