knee-cola / jest-mock-axios

Axios mock for Jest
252 stars 42 forks source link

`getReqMatching`: Add support for Object params #102

Closed jsspiegel closed 3 weeks ago

jsspiegel commented 3 weeks ago

I am making requests that have Array params, and am trying to search for requests with those params using getReqMatching. However, I am not able to do so, since getReqMatching ultimately uses === to compare the criteria params and the request params, and === will always return false in this case when comparing Objects. Ideally, I would like getReqMatching to be able to search for requests with Object params successfully.

Example:

// request: GET /api/request { params: { foo: [1, 2, 3] } }
mockAxios.getReqMatching({ url: "/api/request", method: "get", params: { foo: [1, 2, 3] } })
kingjan1999 commented 3 weeks ago

Hi,

thank you for raising this issue. This should be fixed in 4.8.0.

jsspiegel commented 3 weeks ago

@kingjan1999 Thank you so much for resolving this so quickly!