Skip to main content
Interactive CLI animation

Mocks Server

Node.js mock server

Route variants

Define different responses for the same route, and group them into different mocks. Define responses using plain objects, Express middlewares, or even proxy the requests. Ensure that your API client is ready to handle all cases both in development and testing phases.

Multiple formats

Define routes and mocks using json files or JavaScript files. Babel is supported, so ESM modules and TypeScript can also be used. Hot reload changes the responses in real time once files are changed.

Easy to use

Change the current mock and other settings while the server is running using the interactive CLI or the admin REST API. Integrations with other tools are also available.


Install and start it in seconds. Read get started to know how it works and you will be adding your own routes in minutes.

Configure it using a configuration file, process arguments or environment variables. Use the interactive CLI or the admin REST API for changing settings while it is running.

There are also available packages for integrating the Mocks Server with other development tools. @mocks-server/cypress-commands allows to easily control the mock server from Cypress. Read the Cypress integration chapter for further info

Flexible and maintainable

Define route variants for HTTP responses in JSON files, or as JavaScript objects.

Route variants can be plain objects, Express middlewares, or can proxy requests to another host, and even modify its response.

Group route variants into different mocks.
Mocks can be created extending from another ones, so you can modify or add new routes to the main mock, and the rest of mocks will inherit them.

If this is not enough, you can even add your own route handlers to add more formats for defining route variants.

// mocks/routes/users.json
"id": "get-user",
"url": "/api/user/:id",
"method": "GET",
"variants": [
"id": "success",
"response": {
"status": 200,
"body": { "id": 1, "name": "John Doe"}
"id": "not-found",
"response": {
"status": 404
"id": "proxied",
"handler": "proxy"
"host": ""


Plugins can be easily installed from NPM or developed.

Plugins can do a lot of things in Mocks Server. You could use plugins to provide more interfaces, add more routes handlers, add your own Express routers to the server, etc.

Read also the programmatic usage chapter to learn how to use Mocks Server from your own program.

class MyPlugin {
static id = "mocksLogger"

constructor({ config, onChangeMocks }) {
this._option = config.addOption({
name: "enabled",
type: "boolean",
description: "Log mocks changes or not",
default: true

// ...

Upcoming features

Administration web user interface, Mocking Web Sockets, documentation improvements, etc.

Check the GitHub project to stay up to date on what we are working.

Give it a star on GitHub