axios-mock-adapter
axios-mock-adapter copied to clipboard
Axios adapter that allows to easily mock requests
var axios = require("axios"); var MockAdapter = require("axios-mock-adapter"); // This sets the mock adapter on the default instance var mock = new MockAdapter(axios); // Mock any GET request to /users...
#232 Attempts to provide a helper for adding a delay in milliseconds. The test shows a way to use the method.
This PR adds support for url params taken from named capture groups of regex urls. Below is an example of mocking a request to `/api/foo/1/bar/2` where we need some data...
Fixes #168 Adds the `request` object to the error. This is important and follows [the way that Axios handles errors](https://github.com/axios/axios#handling-errors).
Currently the history only contains the requests sent to axios it doesn't have any information about how that request was handled. I would have liked to just include the handler...
This PR is a bit of a big one, and it's totally fine if you don't think this should be merged, either as-is or ever, but it's here for discussion...
Working with route params is more convenient than defining the regex in the matcher itself (avoids duplication of regexes for similar routes, allows using the same routes you have on...
Similarly to [WebMock](https://github.com/bblimke/webmock) it would be nice if mocking replies will return the handler so that later we can: 1. Assert that mock has been called 1. Remove handler if...
PR related to issue #120.