ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests
MIT License
3.47k stars 245 forks source link

Use AxiosError constructor to create axios errors if available #343

Closed rstein closed 2 years ago

rstein commented 2 years ago

From v0.27.2 axios uses a constructor to create instances of AxiosError. (See https://github.com/axios/axios/pull/3645). This PR uses said constructor to create errors and falls back to the previous behavior for older versions if the constructor is not available. This also fixes #338

ckcr4lyf commented 2 years ago

Thanks for this

Legion2 commented 2 years ago

What is the timeline for this fix? We are currently forced to implement workarounds in our tests.

ctimmerm commented 2 years ago

Tests are failing, I can merge it as soon as they pass.

ckcr4lyf commented 2 years ago

I might take a gander at fixing the tests tonight, if @rstein isn't around

rstein commented 2 years ago

Hi! I have changed the error creation to use the AxiosError.from method. Using new AxiosError seems to cause the stack property to be missing on the error object. Tests are now working for me locally.

ctimmerm commented 2 years ago

Thanks!