When a request is made and wasn't mocked I get an error: Error: Nock: No match for request
but that doesn't fail the test. Is there a way to make sure no mocked requests were made?
Asked
Active
Viewed 953 times
3

Ben
- 871
- 2
- 9
- 18
-
1We need more info. Which testing framework you're using, for one. And when you say "get an error" what does that mean? Is it an uncaught error that is bubbling up or do you just get a log to stdout? The gist is, something is catching your error. In Mocha, for example, if the error was allowed to bubble up, it would fail the test. – Matt R. Wilson Jun 25 '20 at 14:03
-
I'm using Nock with Jest (and React Testing Library) @MattR.Wilson – Ben Jun 28 '20 at 06:47
1 Answers
2
You can catch the "no match" event from nock nock.emitter.on('no match', callback)
and use the callback to trigger the error path in your test framework.

dontcallmedom
- 2,420
- 14
- 12