mock-dev-server is an Express middleware that automatically generates mock API endpoints from a project's `mock/index.js` configuration file. Current stable version is 2.0.0. It supports both simple JSON responses and custom handler functions with full Express 4 semantics, including route parameters. Key differentiators include zero configuration (just place a mock file), support for all HTTP methods, and seamless integration with any Express-based dev server, including webpack-dev-server. It is part of the Alibaba ICE ecosystem but can be used standalone.
npm install webpack-dev-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create an Express app and attach the mock middleware, which automatically loads mock routes from mock/index.js.
Ensure `mock/index.js` exists in the directory where `node` is run.
Install `mock-dev-server` instead of `webpack-dev-mock`.
Use explicit `res.end()` or `res.send()` inside handlers.
Remove options argument; configuration is done solely via `mock/index.js`.
Prefix routes with the desired HTTP method, e.g., 'GET /api/users'.
Run `npm install mock-dev-server --save-dev` and verify package.json.
Create `mock/index.js` with `module.exports = { 'GET /api/test': { message: 'ok' } };`Change `import mockServer from 'mock-dev-server'` to `const mockServer = require('mock-dev-server');`