OSS TanbouSign in with GitHub

reuse network-level API response definitions across browsers and Node.js

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
18,254
Primary language
TypeScript
License
MIT
Repository last updated
Oct 3, 2026
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

Check environment-specific startup and the Node.js requirement

Version 3.0.2 requires Node.js 22.12.0 or later. Browsers use setupWorker, while Node.js uses setupServer, so shared request handlers still need environment-specific initialization.

Sources: [1][2]

Official sources

  1. [1]Mock Service Worker v3.0.2 README(2026-10-04)
  2. [2]Mock Service Worker v3.0.2 package metadata(2026-10-04)
  3. [3]Mock Service Worker v3.0.2 release(2026-10-04)
  4. [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. 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. 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. 3

    Check the mocked response

    Confirm that a normal fetch call receives { name: 'Ada' }.

    node demo.mjs
Check the official README

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

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
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?