Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

expect(fetch).toHaveBeenCalledWith(<url>) doesn't work because it also receives undefined as second argument #52

Open
julienw opened this issue Apr 28, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@julienw
Copy link

julienw commented Apr 28, 2022

The README says:

All the built in jest function inspection assertions can be used, e.g. expect(fetchMock).toHaveBeenCalledWith('http://example.com').

But that doesn't work, indeed it looks like the mock always receives undefined as the second argument, and as a result this fails.

@bshifrin
Copy link

I've noticed this as well. This is a great extension of fetchMock, but errors aren't readable. I've got:

Last call to fetch should have had a URL of http://... but was undefined

That's because lastCall here is an array [url, options] instead of object {url, options}. @wheresrhys @skovhus, any chance you have time to fix this issue?

@wheresrhys wheresrhys added the bug Something isn't working label Jul 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants