🌐
Mock Service Worker
mswjs.io
Mock Service Worker - API mocking library for browser and ...
I found MSW and was thrilled that not only could I still see the mocked responses in my DevTools, but that the mocks didn't have to be written in a Service Worker and could instead live alongside the rest of my app. This made it silly easy to adopt. The fact that I can use it for testing as well makes MSW a huge productivity booster. Kent C. Dodds ... A single source of truth for your network across the entire stack. ... Create, change, and debug fast by augmenting existing APIs—both third-party and local—or designing them as you go.
Docs
This leads to a more resilient setup and, paired with other library features, creates a truly seamless API mocking experience. MSW is designed to be fully environment-, framework- and tool-agnostic. You can use it in any browser or Node.js process without additional configurations, adapters, ...
Quick start
MSW applies on the environment level (Node.js or browser). Integrating it with different tools will come down to finding the appropriate environment entrypoint provided to you by that tool and following the same setup as you did above. For reference, we’ve prepared a curated collection of usage examples: ... Examples of Mock ...
Best practices
You are viewing the docs for MSW 2.0. To access the 1.x docs click here · Our mission is to help you describe the network you want. With that in mind, we have prepared a set of best practices you can employ to improve your network descriptions
Getting started
MSW applies on the environment level (Node.js or browser). Integrating it with different tools will come down to finding the appropriate environment entrypoint provided to you by that tool and following the same setup as you did above. For reference, we’ve prepared a curated collection of usage examples: ... Examples of Mock ...
🌐
Mocks-server
mocks-server.org
Mocks Server
Node.js mock server running live, interactive mocks in place of real APIs. Makes able to define different responses for the same route. The user can choose which response has to be used by each route on each particular moment.
Discussions

mocking - node.js: Mock http request and response - Stack Overflow
Is there convenient way to mock the HTTP Request and Response objects for unit testing middlewares? More on stackoverflow.com
🌐 stackoverflow.com
Please recommend a good API Mocking tool
jest + msw + faker More on reddit.com
🌐 r/node
56
May 16, 2023
I built a lightweight NodeJS mocking server
What's the advantage of this over just mocking the request in a regular test? More on reddit.com
🌐 r/node
20
4
July 31, 2024
Mock unit test an API that uses postgres or integration test API with a "test" database?
For smaller tests or small projects, I mock the DB handler (repository or whatever). For later stuff, I tend to go all the way, have a separate database that gets seeded, all tests are performed against it, then it gets shut down. Testcontainers work well with this. More on reddit.com
🌐 r/node
13
8
December 8, 2023
🌐
Mockoon
mockoon.com › tutorials › nodejs-api-call-and-mocking
Mockoon - Easily call a mock REST API from a Node.js application
Learn how to call a third-party REST API and to mock it with Mockoon when working on your Node.js backend application
🌐
Medium
noone234.medium.com › mocking-an-api-in-node-js-with-nock-0e7a44148cc4
Mocking an API in Node.js with Nock | by Chris Wolfe | Medium
November 15, 2024 - Here’s a minimal example of a Jest test. It mocks a response to a GET request to a specific API. The response has status code 200/OK and a JSON body.
🌐
GitHub
github.com › nock › nock
GitHub - nock/nock: HTTP server mocking and expectations library for Node.js · GitHub
const nock = require('nock') const scope = nock('https://api.github.com') .get('/repos/atom/atom/license') .reply(200, { license: { key: 'mit', name: 'MIT License', spdx_id: 'MIT', url: 'https://api.github.com/licenses/mit', node_id: 'MDc6TGljZW5zZTEz', }, }) This setup says that we will intercept every HTTP call to https://api.github.com. It will intercept an HTTPS GET request to /repos/atom/atom/license, reply with a status 200, and the body will contain a (partial) response in JSON.
Starred by 13.1K users
Forked by 754 users
Languages   JavaScript 96.1% | TypeScript 3.9%
🌐
Mockoon
mockoon.com › tutorials › create-api-nodejs-express-mocking
Mockoon - Create your first API with ExpressJS (or mock it using Mockoon!)
Learn how to create your first REST API and endpoints with the Node.js Express framework or mock it using Mockoon to accelerate your application development
🌐
Kettanaito
kettanaito.com › blog › mocking-in-nodejs-has-just-changed-forever
Mocking in Node.js Has Just Changed Forever - kettanaito.com
February 13, 2025 - Nock is an API mocking library that has been around for almost 15 years. You’ve definitely heard of it and you’ve likely used it as well. It’s extremely popular to this day because it’s extremely good. To me, Nock is also a very special library. When I set off to bring Mock Service Worker to Node.js ...
🌐
Snyk
snyk.io › blog › how-to-mock-api-server-javascript
How to make a mock API server in JavaScript | Snyk
October 20, 2022 - This section will teach you how to create a simple mock API server with Mirage JS. ... Node.js v16 or higher installed on your system.
Find elsewhere
🌐
GitHub
github.com › nahidf › mock-api
GitHub - nahidf/mock-api: A node.js mock api project
mock-api is a simple node.js project that lets you easily mock up APIs, generate custom data, and preform operations on it using RESTful interface.
Forked by 2 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
GitHub
github.com › mocks-server › main
GitHub - mocks-server/main: Node.js mock server running live, interactive mocks in place of real APIs · GitHub
Define your mocked API routes in YAML, JSON, JavaScript or TypeScript files. Mocks Server loads them automatically and watches for changes.
Starred by 312 users
Forked by 20 users
Languages   JavaScript 94.1% | TypeScript 4.7%
🌐
Node.js
nodejs.org › en › learn › test-runner › mocking
Node.js — Mocking in tests
As with all module dependency mocking, this is necessary so that the ago module receives the mock before the ago module is executed (if the mocking does not occur before, it will be too late). This is especially useful when comparing against a static fixture (that is checked into a repository), such as in snapshot testing. PreviousUsing Node.js's test runnerNextCollecting code coverage in Node.js
🌐
npm
npmjs.com › package › api-mock
api-mock - npm
API-Mock is a node.js npm module that generates a mock server (express) from your API specification.
      » npm install api-mock
    
Published   Feb 18, 2016
Version   0.3.2
Author   Evan Cordell
🌐
LogRocket
blog.logrocket.com › home › how to test code that depends on external apis in node.js
How to test code that depends on external APIs in Node.js - LogRocket Blog
June 4, 2024 - Nock can be used to mock individual API responses in a way similar to how we used jest.mock() in the previous section. Like every other Node package, you have to install it first before requiring it in your script:
🌐
npm
npmjs.com › package › node-mock-server
node-mock-server - npm
May 9, 2020 - File based Node REST API mock server. Latest version: 0.25.4, last published: 6 years ago. Start using node-mock-server in your project by running `npm i node-mock-server`. There are 1 other projects in the npm registry using node-mock-server.
      » npm install node-mock-server
    
Published   May 09, 2020
Version   0.25.4
Author   Simon Mollweide
🌐
Better Programming
betterprogramming.pub › build-a-nodejs-mock-server-api-with-random-data-86303db9156a
5 Steps to Build a Node.js Mock Server and API With Random Data
October 20, 2020 - It’s a good idea to start as soon as possible in talking with an external API where your data comes from. In this tutorial, I want to go through a minimal setup for mocking your data. After this, you should be able to extend it with your own data as needed. In order to work with Node, you need to have it installed on your machine. For Mac users, I highly recommend installing it with nvm because it’ll make it easier to update Node.js in the future.
🌐
DEV Community
dev.to › grawl › how-to-mock-an-api-with-random-data-from-nodejs-1j91
How to Mock an API with random data from NodeJS - DEV Community
April 4, 2022 - It's a good idea to start as soon as possible to talk with an external API where your data comes from. In this tutorial, I want to go through a minimal setup for mocking your data. After this, you should be able to extend it with your own data as needed. In order to work with Node you need to have it installed on your machine.
🌐
npm
npmjs.com › package › mockserver
mockserver - npm
August 25, 2019 - To do this, you need to use #import './code.js'; in first line of your mock file: #import './code.js'; Content-Type: application/json; charset=utf-8 Access-Control-Allow-Origin: * { "Random": "Content" } You import javascript modules to create dynamic code responses: ... module.exports = request.body.indexOf('foo') !== -1 ? 'HTTP/1.1 200 OK' : 'HTTP/1.1 400 Bad request' Tests run on travis, but if you wanna run them locally you simply have to run mocha or its verbose cousin ./node_modules/mocha/bin/mocha (if you don't have mocha installed globally).
      » npm install mockserver
    
Published   Aug 25, 2019
Version   3.1.1
Author   Mohammad Hallal
🌐
npm
npmjs.com › package › mock-api-server
mock-api-server - npm
March 26, 2017 - Mock out your API server for testing.. Latest version: 0.4.6, last published: 9 years ago. Start using mock-api-server in your project by running `npm i mock-api-server`. There are no other projects in the npm registry using mock-api-server.
      » npm install mock-api-server
    
Published   Mar 26, 2017
Version   0.4.6