# Mock Service Worker

MIT\-licensed API mocking library that intercepts application requests in browser and Node\.js environments using reusable handlers\.

ID: Q989 · Revision: 1037

Type: software · License: MIT[^license] · Status: active

Website: https://mswjs.io



Mock Service Worker, commonly called MSW, is an open\-source library for controlling application network behavior during development and testing\. Developers define request handlers that can be reused in browser and Node\.js integrations\. This can exercise a frontend's loading, success and error paths without waiting for a real backend, but the mocks are an authored model of that backend rather than proof of its behavior\.[^intro][^quick]

## Capabilities and substitutions

### Reusable API handlers — supported

Handler definitions can serve development and tests with browser or Node integration\.[^intro][^quick]

Use case: Controlled API responses for frontend development and automated tests · Platforms: Browsers with compatible Service Worker support, Node\.js · Region: Version, build and integration requirements apply

### Standalone listening mock server — unsupported

setupServer configures interception inside the current process; it does not create a network server\.[^server]

Use case: Controlled API responses for frontend development and automated tests · Platforms: Browsers with compatible Service Worker support, Node\.js · Region: Version, build and integration requirements apply

### Automatic isolation from real HTTP services — unsupported

Unhandled HTTP traffic can pass through; current listen options default to warning while continuing the frame\.[^defaults][^listen]

Use case: Controlled API responses for frontend development and automated tests · Platforms: Browsers with compatible Service Worker support, Node\.js · Region: Version, build and integration requirements apply

### Cross\-browser and direct\-socket interception — limited

Documented Service Worker/XHR caveats and direct net connection limits prevent blanket coverage\.[^limits]

Use case: Controlled API responses for frontend development and automated tests · Platforms: Browsers with compatible Service Worker support, Node\.js · Region: Version, build and integration requirements apply

### [Substitute for Mockoon](/mockoon) — limited

Can replace a separate Mockoon endpoint for code\-controlled browser/Node application tests by intercepting the application's requests\. It does not replace a shared listening server for arbitrary external clients, and fixtures must be rewritten as handlers\.[^intro][^server][^mockoon]

Use case: Controlled API responses for frontend development and automated tests · Platforms: Browsers with compatible Service Worker support, Node\.js · Region: Version, build and integration requirements apply

## References

[^license]: [MSW license](<https://github.com/mswjs/msw/blob/main/LICENSE.md>) — MIT conditions (vendor; retrieved 2026-10-07T23:03:17Z)

[^intro]: [MSW introduction](<https://mswjs.io/docs/>) — Browser/Node interception and reusable API mocks (vendor; retrieved 2026-10-07T23:02:36Z)

[^quick]: [MSW quick start](<https://mswjs.io/docs/quick-start>) — Handlers, setupServer/setupWorker and lifecycle reset (vendor; retrieved 2026-10-07T23:03:38Z)

[^server]: [MSW setupServer](<https://mswjs.io/api/setup-server>) — Process\-local interception; no listening server; browser\-specific handler APIs (vendor; retrieved 2026-10-07T23:04:01Z)

[^defaults]: [MSW default behaviors](<https://mswjs.io/docs/defaults>) — HTTP passthrough, WebSocket difference and handler order (vendor; retrieved 2026-10-07T23:02:48Z)

[^listen]: [MSW listen options](<https://mswjs.io/api/setup-server/listen>) — onUnhandledFrame warn/error/bypass behavior (vendor; retrieved 2026-10-07T23:05:27Z)

[^limits]: [MSW limitations](<https://mswjs.io/docs/limitations>) — Service Worker/XHR progress/Firefox and direct Node socket limitations (vendor; retrieved 2026-10-07T23:02:48Z)

[^package]: [MSW package manifest](<https://github.com/mswjs/msw/blob/main/package.json>) — Inspected version 3\.0\.2 and protocol\-specific exports (vendor; retrieved 2026-10-07T23:05:27Z)

[^mockoon]: [Mockoon repository](<https://github.com/mockoon/mockoon/blob/main/README.md>) — Desktop\-authored servers and headless CLI (vendor; retrieved 2026-10-07T23:03:50Z)

Source revision: https://substitutefor.net/entities/Q989?revision=1037
