I'm not sure if nock
is supporting awaiting or notifying using callback / event-emitter when the interceptor is called.
For example:
const scope = nock(config.research.url)
.post(config.research.routes.getOdds, expectBody)
.reply(200)
while(true){
expect(scope.isDone()).toBeTruthy()
await sleep(500)
}
How can I improve the above code using nock
API?
nock
emits event on request and response: https://github.com/nock/nock/#events
emit('request', function(req, interceptor, body))
emit('replied', function(req, interceptor))
Your code can listen to the replied
event to get notified.