Open mladenp opened 6 years ago
What does your project and setup look like?
I believe this happens when you do response.json()
for a request to a URL that doesn't return a Content-Type: application/json
header (but something like text/html
) — which works in browser's fetch
, but not in the mock.
Same problem, any workaround here?
I haven't used this in years, but I'd say either tweak the header response to get a proper Content-Type
or if you can't do it, perhaps parse with response.text()
then JSON.parse()
manually.
@BrunoBernardino Thx ur answer, I mock the fetch function by menually, that's works fine for me
@mistricky how did you mock it manually?
I am using this with Create-React-App and react-app-rewired but i am getting error on running tests: