Support for simulating errors
See original GitHub issueNock is excellent! Something that would make it even excellenter is if nock could be used to simulate connection level errors:
nock("http://api.example.com")
.get("/some/path")
.failWith(new Error("socket hang up"));
Especially since these can be otherwise cumbersome to test. Keep up the good work!
Issue Analytics
- State:
- Created 9 years ago
- Comments:19 (1 by maintainers)
Top Results From Across the Web
Simulation Errors
Simulation errors usually cause the simulation to crash. Table 7 below lists common types of these errors and gives examples for each type....
Read more >Troubleshooting Simulation Errors - MATLAB & Simulink
Simscape™ simulations can stop before completion with one or more error messages. This section discusses generic error types and error-fixing strategies. You ...
Read more >The importance of simulated errors in observing system ...
Observing System Simulation Experiments (OSSEs) for numerical weather prediction rely on simulated observations that should include simulated observation errors ...
Read more >Simulating faults in API behavior - WireMock
This is useful for simulating a slow network and testing deterministic timeouts. Use #withChunkedDribbleDelay on the stub to pass in the desired chunked ......
Read more >Time Error Simulation Software | SiTime
Time error analysis using real-time data is a complex and lengthy process that can take from weeks to months to perform. To help...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the end i solved it with something like:
Which looks clean, it does not involve
delay
and stuff, and as it seems to me it is enough to simulateETIMEDOUT
having in mind that im usingrequest-promise
lib where i’m checking forETIMEDOUT
like:if (err.error && err.error.code === 'ETIMEDOUT')
Same can be applied for
ENOTFOUND, ECONNRESET, ECONNREFUSED...
Hi Guys I had this same issue with superagent when trying to test timeout, took about a whole weekend to put it together that it is because superagent always retries requests by default, in fact deafult is
3
[http://visionmedia.github.io/superagent/#retrying-requests](see here) , so on the second retry nock has no url to match thats why you geton setting retry to
0
one gets the correct error, and test passes… 🕺🏾 Hopefully this helps someone