v1.9 • Dev Tools • 8kb gzipped • MIT
MockWire
Request mocking at the network layer, so the same handlers serve tests and local development.

// 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.
// 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
- Runtime scenario switching
- Record and replay mode
- Worker interception for tests
- Reworked the public API for consistency
- Deprecated helpers removed
- Fixed a memory leak on repeated teardown
- Source maps now published with every build
// related
Related products
RouteTiny
A one-kilobyte router with nested routes, lazy segments and no opinion about your view layer.
View →DiffHawk
Structural diffing for objects and arrays, with patches you can apply, invert and store.
View →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.