fetch-mock-jest icon indicating copy to clipboard operation
fetch-mock-jest copied to clipboard

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

Open julienw opened this issue 3 years ago • 1 comments

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.

julienw avatar Apr 28 '22 13:04 julienw

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?

bshifrin avatar Dec 17 '23 17:12 bshifrin