js), I want to test it normally using mocha and chai, but the API is having dependency with external service which I want to mock. Is it possible to mock that internal calls follow the below eg to make a clear picture:
describe('account Link', function() {
it('should return with account status', async function(done) {
nock('http://api.github.com', { allowUnmocked: true })
.get('/users/AKGP')
.reply(200,
{
test: true
});
const options = {
uri: 'http://localhost:3000/internal_api',
body: {},
headers: {
'content-type': 'application/json'
},
method: 'POST',
json: true
}
try {
const res = await rp(options)
console.log(res)
done();
} catch(err){
console.log(err);
done();
}
});
});
// the nocked api is called internally and I am expecting to mock it (http://api.github.com)