axios-mock-adapter
axios-mock-adapter copied to clipboard
Mocking request(object)
I'm trying to mock this code:
axiosInstance
.request(originalRequest)
.then(...);
Where originalRequest is an object like:
{
headers: { },
baseURL: 'http://localhost:3000/test',
method: 'get',
url: '/test'
}
This is supported by axios but results in "Network Error" (that is, passed through to axios) when mocked.
One workaround is to use and mock the default axios instance; then calls to request can be mocked.