Stop intercepting. Call in afterAll.
Start intercepting. Call in beforeAll/beforeEach.
Mock an error response.
Full URL to mock
HTTP error status code
Optionalmessage: stringOptional error message
HTTP method, headers
Mock a JSON response.
Full URL to mock (e.g., 'https://api.example.com/users')
JSON data to return
HTTP method, status code, headers
Reset runtime handlers. Call in afterEach.
MSW-based fetch mock for declarative HTTP mocking in tests.
Replaces the old Cloudflare
fetchMock(undici MockAgent) with MSW'ssetupServer. Works in both Node.js and workerd test environments.Example