
About Mock Service Worker
Mock Service Worker, or MSW, is an open source library for mocking network requests in JavaScript. It intercepts requests at the network level, so the same mocks work with fetch, axios and other clients.
What it does
You describe the endpoints your app calls with request handlers that return mock responses. MSW runs those handlers in the browser through a service worker, or in Node.js for tests. It supports REST, GraphQL, Server-Sent Events and WebSocket APIs with one set of handlers.
Key features
- Request handlers written in Fetch API style
- Works in the browser and in Node.js
- Mocks REST, GraphQL, SSE and WebSocket APIs
- Reuse handlers across tests and development
Who it's for
- Front-end developers building before the API is ready
- Test engineers writing integration tests
- Teams that want one mock setup for many tools
Pricing and good to know
MSW is open source under the MIT license and is free to use. The site also promotes a testing course, which is separate from the library. Check the docs for setup steps that match your framework.
Highlights
- Request handlers written in Fetch API style
- Works in the browser and in Node.js
- Mocks REST, GraphQL, SSE and WebSocket APIs
- Reuse handlers across tests and development












