axios-mock-adapter icon indicating copy to clipboard operation
axios-mock-adapter copied to clipboard

Enhancement Request: onNoMatch function callback

Open codymikol opened this issue 8 months ago • 0 comments

Hello, I'm wondering if you'd accept a PR to add the ability for the onNoMatch option to accept a function callback. This could be very helpful for making integrations with test frameworks.

For example, if I am writing a vitest test and I want to raise a test error that fails the suite given some http requests are not mocked.

const axiosMock = new AxiosMockAdapter(myAxiosInstance, 
  { onNoMatch: (request) => expect.fail("Unexpectedly received unhandled http ${request.verb} request: ${request.url}") }
)

I'm willing to put in the legwork for my use case, just let me know if this work would be accepted, thanks!

codymikol avatar Feb 24 '25 15:02 codymikol