express-supermock
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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 });

Package Sidebar

Install

npm i express-supermock

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

5.95 kB

Total Files

5

Last publish

Collaborators

  • adrian-kriegel