wheresrhys/fetch-mock-jest

Error message when the body of toHaveFetched has a mismatch

shaunak opened this issue · 1 comments

I have a spec that looks something like this

      expect(fetchMock).toHaveFetched(`/my/cool/api`, {
        method: 'POST',
        body: { message: 'this is incorrect', rating: 'thumbs_up' },
      });

Where the body is incorrect - so the test correctly fails, but the error message when I ran the tests output this:

fetch should have been called with /my/cool/api

Implying the API was not even called - however, this is not the case, as when I fixed the body to match the actual output, the test started passing immediately

The issue is probably here:
https://github.com/wheresrhys/fetch-mock-jest/blob/master/jest-extensions.js#L20

The error message is a catch-all for any failure