Friday 21 February 2020

How can i make node offline temporarily during a unit test?

With in a unit test scope i like to make sure all http/https request fail and throw exception if any. I have scenario to test API that suppose to be only called in offline scenario and should not fail if there is no internet. But developer can tend to change low level api and might make rest call for what ever reason. So i like to PR to fail if that ever happen.Given i cannot mess with the CI-Job or vm that it run on. One idea someone gave me was to pollyfill http/https (only interesting in these) function that is use to send request to throw exception and restore them after the offline scope is over. If you guys agree then what is the function i should shadow/override that will helpful in achieving that.Those who will say firewall for the process should know part of the test download data from internet and then other part uses the data and should work offline

Submitted February 21, 2020 at 03:32PM by khanaffan

No comments:

Post a Comment