knee-cola / jest-mock-axios

Axios mock for Jest
252 stars 42 forks source link

mockAxios() isn't compatible with the axios("/get/reqest") call signature #50

Closed evelynhathaway closed 4 years ago

evelynhathaway commented 4 years ago

When calling axios("/my/api/call"), mockAxios.mockResponseFor({ url: "/my/api/call" }) fails to find the request because the URL string is assigned to the config property.

Everything works as expected when using axios.get("/my/api/call") instead as a workaround.

https://github.com/knee-cola/jest-mock-axios/blob/429f7716de4af53eba43e04b621c81b90792e7bb/lib/mock-axios.ts#L22-L25

kingjan1999 commented 4 years ago

Thanks for the report!

Fixed in bb90fee, published as v4.1.0.

evelynhathaway commented 4 years ago

Thanks for getting it fixed so quickly, but I don't see the v4.1.0 version on npm yet.

kingjan1999 commented 4 years ago

That's right, I've accidentally published to the wrong registry (oops :fearful:). Fixed, should appear there soon

evelynhathaway commented 4 years ago

Oh no! It happens, so I hope everything is okay with that. On a positive note, I pulled the new version and the fix works great! Thanks again. ❤️