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
Jest tests failed after upgrading axios to v1.1.2 #5101
Comments
For context: Problem seem to be that Axios is now built as ES Module instead of CommonJs when not run in Node. Problem with Jest is that it runs code in Node, but application is built for web-clients. |
See #5026 |
The change to |
yh |
I found that this did however work for me because it forces those imports to resolve with the CJS module instead: moduleNameMapper: {
'^axios$': require.resolve('axios'),
}, |
@rathpc - i tried your solution. |
this worked, when I restart test command |
Thank you! |
Try upgrading jest to latest (>29.2.x), it worked for me without having to change jest config. |
You save my time! |
Works for me:
|
…eNameMapper to workaround axios/axios#5101 Signed-off-by: Gavin Reynolds <greynolds@pagerduty.com>
Thank you. This worked for me |
Thank You it worked Any permanent solution Found ?? |
"test": "react-scripts test --transformIgnorePatterns "node_modules/(?!axios)/"", Thanks... it works well for me |
Your welcome
I think Issue is in Axios .
…On Tue, Nov 8, 2022, 10:38 PM MatVD ***@***.***> wrote:
"test": "react-scripts test --transformIgnorePatterns
"node_modules/(?!axios)/"",
Thanks... it works well for me
—
Reply to this email directly, view it on GitHub
<#5101 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUUNFPEJE2EHS6XYJ6ARCJDWHKCJZANCNFSM6AAAAAARCLFFFE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Thanks, this works: You can also do it this way:
and you can keep the npm test script as it was before: |
Hi Please try the latest pre-release by running the following: npm i axios@1.2.0-alpha.1 Please provide feedback in either the pinned issue or the discussion thread |
@KonradLinkowski oh whoops |
Just leaving this here. Here is a blurb from the JEST documentation why you have to include axios in transforming/transpiling. By default JEST ignores node_modules/*
|
Yet further useful information why Jest is transpiling |
Finally, the issue is resolved I updated the latest jest version --->npm install --save-dev jest@29.3.1 another way this also working this worked when I restarted the test command |
Add the Axios package to connect to the API so we can get data from the 'dev.to' API. Currently, the latest version of Axios, v1.1.2, does not work with Jest, so we are staying with v0.27.2. Ref: https://axios-http.com axios/axios#5101 (comment)
Add the Axios package to connect to the API so we can get data from the 'dev.to' API. Currently, the latest version of Axios, v1.1.2, does not work with Jest, so we are staying with v0.27.2. Ref: https://axios-http.com axios/axios#5101 (comment)
Up from me ;-) |
…e in axios/axios#5101, then update pact to fix pact-foundation/pact-js#606, and move dev dependencies to dev scope.
No any of the solutions given here gave us a proper solution, we are working with the |
Versions of Axios 1.x are causing issues with Jest (axios/axios#5101). Jest 28 and 29, where this issue is resolved, has other issues surrounding memory leaks (jestjs/jest#7874). Allow `>=0.25.0` for applications that cannot upgrade Jest at this moment.
Checked on |
HI @imransilvake did u not faced error like "options must be an object error" with latest version of axios? AXIOS VERSION used "axios": "^1.3.2", axiosservice.js file looks like below import axios from 'axios'; class AxiosService { none of the solution worked for me . can u please guide me what exactly fixed your issue, and how your axios service.js file looks like Advance |
No, I didn't.
that worked for me:
|
It does even not work for me. |
Not working for me either
Not working me too |
For those of you who tried Made the difference in my project, not sure why... |
We are working with |
same issue with "jest": "^29.5.0", "axios": "^1.3.4" and None of these solutions works for me. |
Update the lib like @pzi said works to me! |
Could you not think of releasing two different libs, one for backend, one for frontend, with different build target or something? How many human life hours have been wasted on this nonsense? |
isn't this library isomorphic? |
"test": "react-scripts test --transformIgnorePatterns "node_modules/(?!axios)/"" |
Describe the bug
I updated the Axios from
"axios": "^0.27.2"
to"axios": "^1.1.2"
, and Jest tests are not working anymore with the following error:To Reproduce
Environment
^v1.1.2
Chrome
Version 105.0.5195.125 (Official Build) (x86_64)
v18.4.0
MAC OS 12.4
^18.2.0
Temporary Fix
The following fix works for now but I expect a standard fix for this issue.
or
The text was updated successfully, but these errors were encountered: