mountebank

raw JSON →
1.4.954 verified Fri May 01 auth: no javascript

mountebank is the first open source tool for cross-platform, multi-protocol test doubles over the wire. It supports HTTP, HTTPS, TCP (text and binary), and SMTP protocols. Current stable version is 2.9.4, published under the @mbtest/mountebank package (was formerly mountebank). The community-driven project requires Node.js >=20. It offers mock verification, stubbing with advanced predicates, JavaScript injection, and record-playback through proxying, distinguishing itself from alternatives like WireMock by supporting multiple protocols and being fully open source without platform constraints. Releases are maintained by the mountebank-testing organization.

error Error: Cannot find module 'mountebank'
cause Using outdated package name mountebank instead of @mbtest/mountebank.
fix
Run npm install @mbtest/mountebank and update imports to '@mbtest/mountebank'.
error TypeError: mb.spawn is not a function
cause Incorrect import of 'spawn' from '@mbtest/mountebank'.
fix
Use import { spawn } from '@mbtest/mountebank'; then const mb = spawn({...});.
error SyntaxError: The requested module '@mbtest/mountebank' does not provide an export named 'default'
cause Using default import when package only exports named exports.
fix
Use named import: import { spawn, Imposter } from '@mbtest/mountebank';
breaking Package name changed from mountebank to @mbtest/mountebank in v2.9.2. Update install commands and imports accordingly.
fix Use `npm install --save-dev @mbtest/mountebank` and update import paths to '@mbtest/mountebank'.
breaking Minimum Node.js version updated to 20 in v2.9.4.
fix Upgrade Node.js to version 20 or higher.
deprecated mountebank v1.x (npm package mountebank) is deprecated; use @mbtest/mountebank v2.x.
fix Migrate to @mbtest/mountebank v2.9.4.
gotcha Node 24 required for Docker image in v2.9.4; local install works with Node 20+.
fix Use Node 20+ for local development; Docker users must use Node 24 image.
breaking nodemailer dependency updated to v8 in v2.9.4, which may break custom email handling.
fix Update SMTP-related code to be compatible with nodemailer v8.
npm install mountebank-test
yarn add mountebank-test
pnpm add mountebank-test

Creates and starts an HTTP imposter on port 3000 with a stub responding to /api/data.

import { spawn, Imposter, Stub } from '@mbtest/mountebank';

const mb = spawn({ port: 2525, loglevel: 'debug' });
const imposter = new Imposter({ port: 3000, protocol: 'http', name: 'test' });
const stub = new Stub().withPredicate({ equals: { path: '/api/data' } }).withResponse({ statusCode: 200, body: { data: 'success' } });
await mb.use(imposter);
await mb.start();
console.log('mountebank running on port 2525');
// ... use imposter ...
await mb.close();