Getting Started
Welcome! ๐
Unmock is a JavaScript library that helps you test API integrations, from third-party services like Stripe and Salesforce to microservices.
Installation
Unmock can be installed via yarn
or npm
.
$ yarn add -D unmock
$ npm install --save-dev unmock
Turning Unmock on and off
To turn Unmock on in any given file, call unmock.on()
. For example, if you are using Jest, it is a good idea to turn Unmock on before each test or before all tests.
const unmock = require("unmock").default;
// import unmock from "unmock"; // ES6
beforeAll(() => {
unmock.on();
}); // Activate unmock to start intercepting traffic
Similarly, you can turn Unmock off with unmock.off()
.
const unmock = require("unmock").default;
// import unmock from "unmock"; // ES6
afterAll(() => {
unmock.off();
});