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

Mocking request(object)

Open TrueWill opened this issue 7 years ago • 1 comments

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.

TrueWill avatar Dec 04 '17 20:12 TrueWill

One workaround is to use and mock the default axios instance; then calls to request can be mocked.

TrueWill avatar Dec 05 '17 20:12 TrueWill