Closed rschristian closed 9 months ago
FYI: These days there is the Response
constructor, so we should be able to do new Response(content, init)
which has all the properties. So instead of stubbing a response we could construct a real one ourselves.
Yup, that's what I was thinking with the second option, which I only though of after I wrote the "probably can't / wouldn't want to" remark.
I should reread what I write before posting.
Just ran into this on
www
, we checkresponse.ok
but the patched fetch here only provides{ text, json}
in the response.There are of course workarounds,
and we probably can't / wouldn't want to mock out everything, but it might be worth considering the following:ok: true, status: 200
etc. props to the return objectreadFile
ahead of time, properly returning 404's, etc.Tbf, only really going to be an issue seen in existing projects.