$ yarn add -D unmock-node
$ npm i -D unmock-node
To activate Unmock and start intercepting internet traffic, call
unmock.on(). Deactivating Unmock is similarly easy -
// import unmock from "unmock-node"; // ES6 const unmock = require("unmock-node").default; // CommonJS beforeAll(() => unmock.on()); // Activate unmock to intercept all outgoing traffic // Test your code... afterAll(() => unmock.off());
unmock.on() takes care of intercepting traffic, but how should Unmock know what data it should serve back to mock the service? That requires defining a service.