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

Add full URL with serialized query parameters to history

Open sean256 opened this issue 4 years ago • 2 comments

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 avatar Aug 11 '21 22:08 sean256

@sean256 I second that!

bdsoha avatar Dec 20 '22 06:12 bdsoha

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.

bdsoha avatar Dec 20 '22 07:12 bdsoha