qmetrics.net

MSW

JavaScript API mocking through network-level request interception

MSW screenshot

Mock Service Worker lets you define HTTP mocks once and reuse them in browsers and Node.js. Applications keep calling real APIs while responses are substituted at the network layer.

Overview

Mock Service Worker (MSW) is a JavaScript library for API mocking in browsers and Node.js. You describe request handlers once and wire them through either a Service Worker in the browser or a Node interception layer, so application code still performs real fetches while selected traffic receives mocked responses.

In the browser, MSW uses the Service Worker API to intercept outgoing requests after they leave your application. Handlers can target REST, GraphQL, server-sent events, and WebSocket traffic. Mocks can appear in developer network tools because the request path stays intact rather than replacing client HTTP code with stubs.

On Node.js, MSW provides setupServer with the same handlers, using a low-level interception approach because Service Workers are unavailable there. The same definitions can support local development, debugging, unit tests, integration tests, and browser end-to-end tooling such as Vitest and Playwright fixtures.

The library emphasizes client-agnostic handlers built around familiar Fetch-style APIs, so mocks are not tied to a single HTTP client. Optional companion projects mentioned in upstream materials include generating handlers from OpenAPI or HAR, data tooling, and serving handlers as HTTP middleware in frameworks like Express, Hono, and Fastify.

Key features

  • Browser Service Worker interception
  • Node.js setupServer API
  • Shared handlers across environments
  • REST, GraphQL, SSE, and WebSocket mocks
  • Playwright network fixture support
  • Storybook addon integration
  • Express server boundary scoping
  • Fetch-oriented handler syntax

Use cases

  • Frontend development without live backends
  • Automated tests with stable network behavior
  • Prototyping API contracts before they exist
  • Debugging UI against error and edge responses
  • End-to-end tests with realistic request paths

Tags

Similar software

Swagger UI

Interactive OpenAPI reference documentation UI

Swagger UI renders OpenAPI and standalone JSON Schema specs as browsable, try-it-out API documentation in the browser. It ships as npm packages or static assets for your site.

  • OpenAPI-driven doc generation
  • Try-it-out request console
  • Multiple OpenAPI version support
JavaScriptWebDetails →
★ 29.1k⟳ todayApache-2.0

GraphiQL

GraphQL IDE, language service, and editor integration toolkit

An official GraphQL Foundation monorepo with the GraphiQL browser IDE, language services, LSP server, and editor modes for GraphQL development.

  • In-browser GraphiQL IDE in React
  • Shared GraphQL language service package
  • LSP server and CLI for editor extensions
TypeScriptWeb, CLIDetails →
★ 17k⟳ todayMIT

Scalar

OpenAPI-native API references, client, and docs tooling

Scalar is an open-source API platform centered on OpenAPI and Swagger. It offers interactive API references, an offline-first API client, and related docs and agent-facing tooling.

  • OpenAPI and Swagger rendering
  • Built-in API testing
  • Multi-language code examples
TypeScriptWeb, Linux, macOS, WindowsDetails →
★ 16.5k⟳ todayMIT
Open Source Alternative to:Postman

swag

Go annotation-driven Swagger 2.0 API documentation generator

Swag reads declarative comments in Go source and emits Swagger 2.0 specs plus a docs package for frameworks such as Gin. A CLI formats comments, initializes docs, and supports Docker or binary installs.

  • Swagger 2.0 generation
  • Declarative Go comments
  • Gin framework integration
GoDockerDetails →
★ 13k⟳ 2 months agoMIT · open core

REST Client

HTTP and GraphQL client inside Visual Studio Code

REST Client sends HTTP, GraphQL, and cURL requests from editor files and shows highlighted responses, variables, auth, and history in VS Code.

  • Send HTTP requests from .http files
  • GraphQL query and variables support
  • cURL import and copy as cURL
TypeScriptDetails →
★ 6.1k⟳ 10 months agoMIT

Hey API

OpenAPI-driven SDK and schema code generation ecosystem

Hey API turns OpenAPI specifications into TypeScript and Python clients, validators, mocks, and related artifacts using openapi-ts and openapi-python with many optional plugins.

  • openapi-ts TypeScript generator
  • openapi-python SDK generator
  • Twenty-plus generation plugins
TypeScriptDetails →
★ 5.6k⟳ 2 months agoMIT