# mswjs/msw

Industry standard API mocking for JavaScript.

Repository: https://github.com/mswjs/msw
Canonical: https://ross.abutalabs.com/products/msw
Homepage: https://mswjs.io
Language: TypeScript
License: MIT
License Family: permissive
Topics: msw, mock, mocking-framework, service-worker, mock-service-worker, mocking, mocking-library, api-mocking, devtools, api, mswjs
Last push: 2026-07-24T08:54:35+00:00

## Health v2 (maintenance only)
Score: 90/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 94, release rhythm 80, longevity 100
- inputs: {"age_days": 2850, "days_push": 40, "days_rel": 57, "gap_med": 3.0, "n_releases_24m": 87}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 18168, forks 619 (observed 2026-08-28T04:11:26.400897+00:00)

## What it is
Mock Service Worker (MSW) is an API mocking library for JavaScript that intercepts HTTP, GraphQL, and WebSocket requests in browsers via the Service Worker API and in Node.js via class extension. It lets you define request handlers once and reuse the same mocks across development, unit/integration/e2e tests, Storybook, and demos.

## Use cases
- mock rest api responses in jest or vitest tests
- intercept fetch and axios requests during development
- mock graphql queries for frontend testing
- reuse api mocks across storybook and e2e tests
- simulate network delays and error responses
- develop frontend before backend api exists
- mock websocket connections in tests

## When to choose
- you need environment-agnostic mocks reusable across browser and Node.js
- you want mocks that don't patch your app code and stay visible in DevTools
- you're testing frontends that talk to REST, GraphQL, or WebSocket APIs
- you want a single source of truth for network behavior across tools

## When to avoid
- you only need simple function/module mocking rather than network-level mocking
- you're mocking non-HTTP protocols or backend-to-backend gRPC services
- you need contract testing against real API specifications

## Facets
- artifact type: library
- maturity: stable
- function: mocking, testing, http-client, graphql, websocket, developer-tools
- domain: testing, web-development, frontend, developer-tools, apis
- platform: browser, cross-platform
- tags: api-mocking, service-worker, request-interception, mock-service-worker, test-utils, storybook, nodejs, web-server

## Member repositories
- mswjs/msw (main) score 90

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:11:26.400897+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:02:08.115217+00:00, confidence not recorded.
  - readme: https://github.com/mswjs/msw (fetched 2026-08-28T04:11:26.400897+00:00, sha 96bd2a0cb814)
  - homepage: https://mswjs.io (fetched 2026-08-29T08:00:27.347389+00:00, sha de2eb2dc6f92)
  - site_page: https://mswjs.io/docs (fetched 2026-08-29T08:00:27.356647+00:00, sha b9af0b92c640)
  - site_page: https://mswjs.io/docs/quick-start (fetched 2026-08-29T08:00:27.358819+00:00, sha 70e1d18f6a4a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
