wheresrhys/fetch-mock-jest

Implement` toHaveRespondedWith`

Closed this issue · 3 comments

toHaveRespondedWith(object | status | string ) (using fetch-mock internals to convert to a response config, then use jest objectMatching)

fetch-mock itself does not provide any utilities for inspecting responses.

On the one hand it does feel useful to allow inspecting responses, but on the other hand, there are 2 cases to consider

  1. User has defined a mock response, in which case it's a bit odd to want to check the response that was sent as you would be testing that the mock - not the src - behaves as expected
  2. Spying on a real fetch response, but in this case it still feels a little odd to want to check things across the clear boundary that the server/client split makes

Will leave implementing anything in this space until real users request it with compelling reasons

merry christmas git hub issue rhys

@wheresrhys I totally agree with both of your considerations. Seems superfluous