All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- added more documentation for
matcher
,response
, andoptions
parameters
- changed min version for axios as a required peer dependency increased to v1.5.0 (exports
getAdapter
)
- fixed passthrough scenario (was broken since axios v1.2.0)
- fixed route matching with relative
url
(string matcher): is now usingaxios.baseURL
to turn relative URL into absolute URL - fixed URL param matching for the edge case of having multiple params with the same name
- fixed route matching with
matcher.query
(was causing a runtime error when used with relative URLs) - fixed route matching with relative
url
(string matcher)
- you can now define a response with
status
,statusText
,data
,headers
matcher.query
is now checked against both: parameters set via axios requestoptions.params
and URL parameters defined directly in the URL string via?foo=bar
- added
module
key to package.json - added
sideEffects: false
to package.json
- the default export is no longer a
Mock
instance (wired to the defaultaxios
instance) but instead is the library'sbase
object that can be used to.create()
aMock
instance. So importingaxios-response-mock
(without calling any functions) is side-effect-free (see https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free)
- response
statusText
is now set according tostatusCode
- mock error responses now use either
Error
orAxiosError
instances (corresponding to the used axios version)
- removed experimental
module
key from package.json, was causing issues when package was used with older browsers
- dist bundle transpiled to ES5 to support IE11 (was ES6)
- Basic documentation for
.create(),
.restore()
,.mock()
, and shorthand functions for.mock()
- Support for response
delay
option - Changelog
- When a function is provided as the
response
argument for.mock()
the function result was formerly treated as the payload of a success response (status 200), this is now changed so the result is processed as if it was provided directly as theresponse
argument. This for example allows a function to contain a switch to return 200 or 400 or any other HTTP status code and trigger a corresponding response
- Status codes other than those in the 200-299 range will now correctly trigger a
Promise reject
instead of aresolve
.
- Basic response mock implementation