Jest tests failed after upgrading axios to v1.1.2
Problem
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: [code block] To Reproduce 1. Use React and Axios latest version 2. Create Jest test 3. Run the test to generate the error Environment - Axios Version `^v1.1.2` - Browser `Chrome` - Browser Version `Version 105.0.5195.125 (Official Build) (x86_64)` - Node.js Version `v18.4.0` - OS: `MAC OS 12.4` - React: `^18.2.0` Temporary Fix The following fix works for now but I expect a standard fix for this issue. [code block] or [code block]
Error Output
Error: Cannot use import statement outside a module
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Jest tests failed after upgrading axios to v1.1.2
I found that this did however work for me because it forces those imports to resolve with the CJS module instead: [code block]
Trust Score
9 verifications
- 1
I found that this did however work for me because it forces those imports to res
I found that this did however work for me because it forces those imports to resolve with the CJS module instead:
Validation
Resolved in axios/axios GitHub issue #5101. Community reactions: 124 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep