Search code examples
nock

Nock: how to assert request wasn't made


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?


Solution

  • 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.