Mock Config logoMock config

Comparison

Compare Mock Config with similar API mocking tools.

Choosing the right mocking tool depends on what you need to emulate, where your application runs, and how much control you want over scenarios.

Comparison goal

This page is not about declaring one tool universally better than another. Different libraries solve different problems well. The goal here is to make the tradeoffs visible and explain where Mock Config fits especially well.

Comparison Criteria

These are the criteria we use when comparing Mock Config with alternatives:

  • supported API types
  • environment
  • implementation
  • integration
  • definition

MSW

MSW is one of the closest alternatives to Mock Config.

MSW is especially strong when you want request interception directly in the app runtime. Mock Config is stronger when you want one explicit config for REST, GraphQL, WebSocket, and scenario-driven mock behavior.

API Support

API typeMock ConfigMSW
REST API
GraphQL queries and mutations
WebSocket API
GraphQL subscriptions over WebSocket

Supported Environments

EnvironmentMock ConfigMSW
Node.js
Browser
React Native

Implementation

CriteriaMock ConfigMSW
ModelDedicated mock runtimeRequest interception
Transport setupREST, GraphQL, WebSocket in one configHTTP, GraphQL, WebSocket interception APIs

Integration

CriteriaMock ConfigMSW
CLI workflow
Programmatic Node.js API
Separate runtime process
No app code changes

Definition

CriteriaMock ConfigMSW
Main styleConfig-driven helpersHandler-driven interception
RESTrest.get(...)http.get(...)
GraphQLgraphql.query(...)graphql.query(...)
WebSocketws.connection(...), ws.message(...)ws.link(...) and socket events
Scenario selectionBuilt-in MatcherHandler logic and overrides

Mock Config keeps mocks in a dedicated config and adds scenario selection through matchers. MSW keeps mocks close to request interception and models them as handlers.

Mock Config

rest.get<{ params: { id: string } }>('/users/:id', ({ request }) => ({
  id: Number(request.params.id),
  name: 'John'
}));

MSW

http.get('/users/:id', ({ params }) => {
  return HttpResponse.json({
    id: params.id,
    name: 'John'
  });
});

Mock Config is a stronger fit when you want one explicit config for REST, GraphQL, WebSocket, and GraphQL subscriptions over WebSocket.

Nock

Nock is an HTTP server mocking and expectations library for Node.js.

Nock is a very solid Node.js choice for HTTP mocking and expectations. Mock Config covers a broader API surface with first-class GraphQL and WebSocket support.

API Support

API typeMock ConfigNock
REST API
GraphQL API
WebSocket API

Supported Environments

EnvironmentMock ConfigNock
Node.js
Browser

Integration

CriteriaMock ConfigNock
No app code changes
Works across request clients

Definition

CriteriaMock ConfigNock
Main styleRoute configMethod chaining
Examplerest.get('/user', ...)nock(...).get(...).reply(...)

Nock uses method chaining and is very direct for HTTP mocking in Node.js. Mock Config uses transport helpers and keeps the route behavior in one config format.

Nock

nock('https://api.example.com').get('/user').reply(200, {
  id: 1,
  name: 'John'
});

Mock Config

rest.get('/user', {
  id: 1,
  name: 'John'
});

JSON Server

JSON Server creates an actual HTTP server from JSON resources.

JSON Server is great when a quick resource-based REST backend is enough. Mock Config is a better fit when you need explicit routes, richer scenario control, GraphQL, or WebSocket behavior.

API Support

API typeMock ConfigJSON Server
REST API
GraphQL API
WebSocket API

Supported Environments

EnvironmentMock ConfigJSON Server
Node.js
Browser

Integration

CriteriaMock ConfigJSON Server
No app code changes
Separate runtime process

Definition

CriteriaMock ConfigJSON Server
Main styleExplicit route configResource-first JSON
Dynamic scenarios

JSON Server starts from resources and derives routes from data. Mock Config starts from routes and scenarios, which gives you more explicit control over behavior.

JSON Server

{
  "users": [
    { "id": 1, "name": "John" },
    { "id": 2, "name": "Jane" }
  ]
}

Mock Config

rest.get('/users', [
  { id: 1, name: 'John' },
  { id: 2, name: 'Jane' }
]);

Mirage

Mirage is an API mocking library with route handlers and in-memory data modeling.

Mirage shines when data modeling is the center of the mocking strategy. Mock Config focuses more on transport-level scenarios, matching, and reusable runtime behavior.

API Support

API typeMock ConfigMirage
REST API
GraphQL API
WebSocket API

Supported Environments

EnvironmentMock ConfigMirage
Node.js
Browser

Implementation

CriteriaMock ConfigMirage
ModelDedicated mock runtimeBrowser patching and in-memory server
Data modelingExternal or customBuilt in

Definition

CriteriaMock ConfigMirage
Main styleConfig helpersRoute handlers and models
Scenario focusMatchers and explicit scenariosData-first modeling

Mirage is built around route handlers and in-memory modeling. Mock Config is lighter when the main goal is to emulate transport behavior without introducing a built-in data layer.

Mirage

createServer({
  routes() {
    this.get('/movies', () => ['Interstellar', 'Dunkirk']);
  }
});

Mock Config

rest.get('/movies', ['Interstellar', 'Dunkirk']);

Cypress cy.intercept()

Cypress provides API mocking through cy.intercept().

cy.intercept() is a natural fit inside Cypress tests. Mock Config is more reusable when the same mocked behavior must work outside the test runner too.

API Support

API typeMock Configcy.intercept()
REST API
GraphQL API
WebSocket API

Supported Environments

EnvironmentMock Configcy.intercept()
Node.js
Browser

Implementation

CriteriaMock Configcy.intercept()
ModelDedicated mock runtimeTest-runner interception
AvailabilityApp and testsCypress only

Definition

CriteriaMock Configcy.intercept()
Main styleConfig helpersCustom matcher and reply callbacks
Reuse outside tests

cy.intercept() is great when the mock only needs to exist inside Cypress. Mock Config is more reusable when you want the same behavior in local development and tests.

cy.intercept()

cy.intercept('POST', '/users', (request) => {
  request.reply({
    statusCode: 201,
    body: request.body
  });
});

Mock Config

rest.post('/users', ({ body }) => ({
  id: 1,
  ...body
}));

Playwright page.route()

Playwright provides request mocking through page.route().

page.route() works well for browser-level test routing. Mock Config is stronger when you want the same scenarios available in local development, Node.js, and automated testing with one shared config.

API Support

API typeMock Configpage.route()
REST API
GraphQL API
WebSocket API

Supported Environments

EnvironmentMock Configpage.route()
Node.js
Browser

Implementation

CriteriaMock Configpage.route()
ModelDedicated mock runtimeBrowser-level routing in Playwright
AvailabilityApp and testsPlaywright browser context only

Definition

CriteriaMock Configpage.route()
Main styleConfig helpersRoute continuation and fulfill handlers
Reuse outside tests

page.route() works well for browser test routing. Mock Config is better when you want a standalone mock layer that is shared outside Playwright too.

page.route()

await page.route('**/users', async (route) => {
  await route.fulfill({
    status: 200,
    json: [{ id: 1, name: 'John' }]
  });
});

Mock Config

rest.get('/users', [{ id: 1, name: 'John' }]);

On this page