1.0.3 • Published 1 year ago

express-supermock v1.0.3

Weekly downloads
49
License
MIT
Repository
github
Last release
1 year ago

express-supermock

Mock thrid party apis using superagent and express.

// require or import
const { supermock, mock } = require('express-supermock');

// re-route all traffic from api.example.com to your mock implementation

// using an express app
mock('api.example.com', { app: myExpressApp });

// using an express router
mock('api2.example.com', { router: myExpressRouter });

// using just a simple callback
mock('api3.example.com', { handler: (req, res, next) => {...} });

Then use the supermock object like you would use superagent or replace it using proxyquire.

// myModule's superagent will now re-route to your mock implementation
const myModule = proxyquire('my-module', { superagent: supermock });