A lightweight mock server built on top of Express.js for rapidly creating fake API endpoints during development and testing. Current stable version is 3.4.3 with an active release cadence. Key differentiators include a declarative JSON-based routing configuration, support for dynamic responses via functions, and an optional control API for runtime manipulation.
npm install express-mock-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Start a mock server with a single route returning a JSON array. Uses ESM import and demonstrates basic source file format.
Use import syntax or dynamic import(). If you must use require, stick to v2.x.
Ensure response.body is a string, e.g., JSON.stringify({ key: 'value' }).Always specify method: 'GET', 'POST', etc. to avoid unintended matches.
Flatten your sources to a single array of route objects.
Run 'npm install express-mock-server' and use 'import { serverStart } from 'express-mock-server''.Use 'import { serverStart } from 'express-mock-server'' or 'const { serverStart } = await import('express-mock-server')'.Switch to ESM (e.g., type: 'module' in package.json) or use dynamic import.