개발관련/리액트
CRA test 할때 axios import outside 에러 관련
개발자 Dane
2023. 5. 1. 21:25
반응형
axios 내부에서 import 구문을 사용해서 생기는 에러로 보인다.
babel 설정등을 수정하면 해결될 문제이지만 CRA 특성상 커스텀하는게 더 귀찮다.
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!axios)/\"",
이런식으로 package.json 에서 test script에 옵션을 추가하면 해결된다.
axios 최신 버전에서 생기는 이슈로 보인다. 일반적인 에러가 아니라서 원인을 찾는데 꽤 어려웠음.
https://github.com/axios/axios/issues/5101
Jest tests failed after upgrading axios to v1.1.2 · Issue #5101 · axios/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: FAIL src/app/slices/app/App.slice.test.tsx ● Test...
github.com
반응형