Vue · Senior · Question 66 of 75
How do you mock API calls in component tests without mocking fetch per test?
- ✓Correct answer: Intercept requests at the network level with Mock Service Worker (MSW) handlers
- 2Replace
window.fetchwithundefined - 3Call the real API
Explanation
The same handlers can be reused in tests, Storybook and local development, and tests stay independent of the HTTP library.