Friday, 26 July 2019


nock is very useful to mock your network calls.

the times function is very useful.

if you don't call it, it will be just one time by default.

it is very useful, if your want to test a code which do retry with some special case e.g. status= 401.

then you can :

.reply(200, [
name: 'peter'

in this case, the first 2 times the endpoint called the server will return 429,    them the 3rd time call will return 200.

which help you to test your retry logic.

No comments:

Post a comment