-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"TypeError: response.body.getReader is not a function" for HTTPResponse of JSON type #2123
Comments
Smells a lot like the whatwg-fetch-esque style problem: using a non-spec compliant Response polyfill more info about it here: if you use the Response global from node >=18 in your test environment I think your issue will be resolved. I’d be happy to verify if you could post your package.json dependencies and show your relevant test setup files/configuration |
Thanks for the response @akmjenkins. One important thing to note here, I generated this project using NX and its using @nx/jest plugin. I fixed my test environment setup and added jest polyfills(mentioned below) which fixed above issue but now I am getting AxiosNetwork error.
Polyfills
|
This is an issue with Jest. Most likely related to Here are a few references that I hope will prove helpful to you:
I'm closing this because I will not look into Jest/JSDOM-related issues (but anyone is welcome to dive into this, I don't mean to discourage you either!). No amount of time I invest into this will make those tools any less broken. If you can, migrate to Vitest. If you can't, raise this in the Jest repo. The more people raise these problems, the more likely Jest will fix them. Nothing we can or should do on MSW's side—it's using valid standard JavaScript. |
@kettanaito Thank you for your response, from one of the references you have provided in your response, I read that downgrading undici to v5 helped someone. I tried that and apparently I no longer see Axios network error and my test cases seem to be working. |
@schok-d, that's great news! So, it was the |
Prerequisites
Environment check
msw
versionNode.js version
v20.11.0
Reproduction repository
NA
Reproduction steps
NA
Current behavior
I am trying to mock a simple JSON response for API for a React application that use Axios.
Seeing this error: TypeError: response.body.getReader is not a function.
The text was updated successfully, but these errors were encountered: