Mock Service Worker

mswjs.io APIs & Databases Online toolFreeOpen source

A JavaScript API mocking library that shares request handlers between browser development and automated tests.

mswjs.io
Mock Service Worker homepage screenshot

About Mock Service Worker

Mock Service Worker is an open source JavaScript library for mocking API requests. It lets developers describe network responses once, using request handlers written in the Fetch API style, and reuse those handlers across frameworks, tools, and environments.

In the browser, it uses the standard Service Worker API to intercept requests. In Node.js, it intercepts requests at the socket level through @mswjs/interceptors. The library can mock REST, GraphQL, Server-Sent Events, and WebSocket APIs under one contract. Its examples show integration with Playwright, Vitest-style test setup, and Storybook, and it can be enabled only in development builds.

Key features

  • Shared request handlers for browser development and Node.js tests
  • Mocks REST, GraphQL, Server-Sent Events, and WebSocket APIs together
  • Handlers written with the Fetch API request and response model
  • Browser request interception through the standard Service Worker API
  • Node.js request interception through @mswjs/interceptors
  • Generates request handlers from OpenAPI documents and HAR files
Best for: JavaScript developers and teams who want the same API mocks in browser development and automated tests.
Good for
  • Handlers use the Fetch API model, so the same mock code can be reused across tools
  • One mock definition can cover browser development and Node.js test environments
  • Free and open source

Mock Service Worker at a glance

Website
mswjs.io
Type
Online tool
Pricing
Free
Open source
Yes
Last checked
Oct 9, 2026 · Online when checked
Listed
Oct 9, 2026

Mock Service Worker alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 7 alternatives

WireMock

wiremock.org

An open-source HTTP mocking server for request matching, simulated responses and automated integration tests.

FreeOpen source
12 alternatives

MockServer

mock-server.com

An HTTP mocking and proxy server with request expectations, response configuration and verification APIs.

FreeOpen source
11 alternatives

HTTPie

httpie.io

HTTPie provides API testing clients for the terminal and desktop, with documentation and request workflows.

Rest Test Test

resttesttest.com

Compose and send HTTP requests with this REST testing interface, which includes method, endpoint, and request options.

Postman

postman.com

Postman is an API development platform for sending requests, inspecting responses and maintaining collections and environments. Its Free plan covers individual API work, while shared team workflows and some automation features use paid plans.

Bruno

usebruno.com

Bruno is an API client that stores collections as local files for use with Git and other version-control workflows. The open-source edition handles personal request testing and collection runs; paid editions add integrations and in-app conveniences.

FreemiumOpen source
10 alternatives

Popular in APIs & Databases

Well-known listings from the same topic.

All 93

Mock Service Worker FAQ

Can the same mocks be used in browser development and in tests?
Yes. Handlers are described once and can be used with the browser setup for development and the Node.js setup for tests.
Can handlers be generated from existing API definitions?
The library lists the ability to generate request handlers from OpenAPI documents and HAR files instead of writing them by hand.
Can mocks return error responses?
Yes. Handlers can return a custom status code, such as a 429 rate limit response, to test how an interface handles errors.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing