node.js - How to mock a third-party api calls in the backend -


i'm testing application mocha , supertest, test like

var request = require('supertest'),     app = require('./bootstrap.js');  describe('...', function() {   it('...', function() {     request(app)       .get('/some/url')       // ...   }); 

});

the bootstrap.js real application before listen ports

all works perfect have add calls third-party api , testing slow

so when do, test example takes 5 seconds

request(app)   .get('/my/endpoint/that/makes/call/others')   // ... 

how can make fake calls during test real when running application?

you can use nock purpose.


Comments

Post a Comment

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -