wheresrhys / fetch-mock-jest

Jest wrapper for fetch-mock, a comprehensive stub for fetch

Home Page:http://www.wheresrhys.co.uk/fetch-mock/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message when the body of toHaveFetched has a mismatch

shaunak opened this issue · 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