axios-mock-adapter
axios-mock-adapter copied to clipboard
Add full URL with serialized query parameters to history
I've run into a case where I needed to customize axio's paramsSerializer to change the default handling of array serialization.
It would be super if we could test for proper param serialization with this mock adapter.
My suggestion would be to add a new fullUrl to the history entries which includes the serialized parameters.
@sean256 I second that!
After a second look, I noticed that the history object is returning a native axios object that does not have a fullUrl equivalent parameter.
https://github.com/ctimmerm/axios-mock-adapter/blob/37a2875003155b8a7013563efb3e8090cd457b60/types/index.d.ts#L64
Solution
Instead of basing my tests on the generated output of a custom paramsSerializer, I added assertions for the params passed in object form to the request.
In addition, I extracted the value of the paramsSerializer function and separately added a full series of tests at the unit-level.