On this page
Overview
This library replaces API responses during JavaScript application development and testing. It uses a Service Worker in browsers and low-level request interception in Node.js, so applications can exercise their normal request code without replacing the HTTP client.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Respond to requests while preserving the application's request path
Handlers can match paths, parameters, wildcards, and regular expressions, then return responses with status codes, headers, cookies, and delays. Browser responses also remain visible in the Network panel.
Sources: [1]
Best fit
Share network definitions between development and test stages
It fits interface work against unfinished APIs and tests that need repeatable success or failure responses from external services. The same request handlers can support local development and unit, integration, and end-to-end tests.
Sources: [1]
Before adoption
Official sources
- [1]Mock Service Worker v3.0.2 README(2026-10-04)
- [2]Mock Service Worker v3.0.2 package metadata(2026-10-04)
- [3]Mock Service Worker v3.0.2 release(2026-10-04)
- [4]Mock Service Worker v3.0.2 license(2026-10-04)
Supplemental curator note
Its main advantage over replacing an API client directly is that application requests still travel through the normal call path. When adopting v3, verify the Node.js version and environment-specific imports in a small test first.
Try it in 3 steps
- 1
Add v3.0.2 to an isolated project
Use Node.js 22.12.0 or later and install the reviewed version in a small project.
mkdir -p msw-demo && cd msw-demo && npm init -y && npm install msw@3.0.2 - 2
Create a Node.js request handler
Save a minimal example that returns JSON for a GET request without contacting an external service.
printf '%s\n' "import { http, HttpResponse } from 'msw/http'" "import { setupServer } from 'msw/node'" "const server = setupServer(http.get('https://example.test/user', () => HttpResponse.json({ name: 'Ada' })))" "server.listen({ onUnhandledRequest: 'error' })" "const response = await fetch('https://example.test/user')" "console.log(await response.json())" "server.close()" > demo.mjs - 3
Check the mocked response
Confirm that a normal fetch call receives
{ name: 'Ada' }.node demo.mjs
Growth
Growth trends · Last 30 days
18,254 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 12
- Open PRs
- 1
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- msw
- mock
- mocking-framework
- service-worker
- mock-service-worker
- mocking
- mocking-library
- api-mocking
- devtools
- api
- mswjs
- Stars
- 18,254
- Forks
- 628
- Watchers
- 65
- Open issues
- 12
- Contributors
- 182
- Owner type
- Organization
- Primary language
- TypeScript
- License
- MIT
- Repository last updated
- Oct 3, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Elysia19,216 Stars
1 shared tag(s) · 1 shared category(s) · Same language
build TypeScript web APIs around Bun with end-to-end type safety, runtime validation, and Web Standard adapters
TypeScript - Apollo Server13,951 Stars
1 shared tag(s) · 1 shared category(s) · Same language
build Node.js GraphQL APIs from schemas and resolvers
TypeScript - Hoppscotch80,561 Stars
2 shared tag(s) · 2 shared category(s) · Same language
Span REST, GraphQL, realtime requests, and collection tests across web, desktop, CLI, and self-hosted API workflows
TypeScript - WireMock7,387 Stars
2 shared tag(s) · 2 shared category(s)
Virtualize HTTP APIs with request matching, dynamic responses, delays/faults, and record/playback in a mock server or library
Java - Insomnia40,036 Stars
1 shared tag(s) · 2 shared category(s) · Same language
combine API design, requests, testing, and CI workflows in a desktop client
TypeScript - Bruno47,337 Stars
1 shared tag(s) · 2 shared category(s)
manage API collections as local Bru files in Git and run them from desktop, CLI, or CI
JavaScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.