ctimmerm / axios-mock-adapter

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

Compatibility Issue with axios@v1 #349

Closed mpyw closed 1 year ago

mpyw commented 2 years ago

🤮 Fix axios and axios-mock-adapter compatibility issue on tests 🤮 by mpyw · Pull Request #48 · mpyw/axios-case-converter

The two critical problems are:

  • The value returned from axios-mock-adapter mock definitions must be an AxiosHeaders object, otherwise the instance reference will be changed.
  • axios does not expose AxiosHeaders constructor.

While not a bug, axios@v1 still has a problem for testability.

Returning response headers on mock response definition won't work anymore in some cases. The dirty hack will be needed, otherwise we need to make it exposed in axios core.

mpyw commented 2 years ago

CC @jasonsaayman

marcbachmann commented 1 year ago

I think this got fixed. Please use the newest version.