Skip to content

v1.9 • Dev Tools • 8kb gzipped • MIT

MockWire

Request mocking at the network layer, so the same handlers serve tests and local development.

★ 4.9kGitHub
↓ 4.0k / week● MIT● TS 5.0+
mockwire-preview.png
Abstract preview graphic for MockWire

// why mockwire

One set of handlers

The same mock definitions run in tests, in the browser during development and in a storybook, because they intercept at the network boundary.

● 0 deps● 18ms cold start● CI ready

// stack

No code branching

Your application code never knows it is being mocked, so tests exercise the real request path.

MockWire started as a single file in a client project and stayed small on purpose. It does one job, it does it in 8kb gzipped, and it has no runtime dependencies.

Getting started

Install it, import it, call it:

npm i mockwire-js

The same mock definitions run in tests, in the browser during development and in a storybook, because they intercept at the network boundary.

What it does not do

It does not manage your state, style your components or ship a plugin system. Those are your decisions, and keeping them out is what keeps the bundle honest.

  • Scenario switching
  • Record and replay
  • MIT licensed, commercially friendly

Features

Scenario switching

Flip between success, error and slow-network scenarios at runtime without a rebuild.

Record and replay

Capture real responses once and replay them deterministically afterwards.

Readable reports

Terminal output for humans, JSON for everything else.

ESM and types

Ships module and CommonJS builds with hand-written type definitions and source maps.

CI first

Exits with a meaningful status code and prints machine-readable output on request.

Config optional

Sensible defaults mean MockWire does something useful before you configure anything.

Get MockWire v1.9

12 files • .min.js 8kb • .zip 49kb • sha384 verified

Changelog

v1.9 Nov 28 2025 • latest
  • Runtime scenario switching
  • Record and replay mode
  • Worker interception for tests
v1.8.4 Oct 20 2025
  • Reworked the public API for consistency
  • Deprecated helpers removed
v1.8.3 Jul 26 2025
  • Fixed a memory leak on repeated teardown
  • Source maps now published with every build
View full archive →

// related

Related products

Apr 09 • v2.2

RouteTiny

A one-kilobyte router with nested routes, lazy segments and no opinion about your view layer.

View →
Dec 20 • v3.0

DiffHawk

Structural diffing for objects and arrays, with patches you can apply, invert and store.

View →
Dec 09 • v2.6

BundleLens

Bundle analysis that tells you which import cost you the weight, not just which file is large.

View →

Wire it into CI today.

MIT licensed. Commercial friendly. Five-minute setup.