我在 React 应用程序中使用 axios 以及 MUI 进行样式设置。我在开发时没有错误,但现在当我开始使用我的 React 应用程序编写测试时react testing library,jest我收到 axios 模块错误,如下所示。我查阅了很多文章,很可能是因为 axios 将模块类型从 CommonJS 更改为 ECMAScript。我尝试在 React 中修改Vue.js 的这个解决方案,但我做不到。
FAIL src/components/user/Contact.test.js\n \xe2\x97\x8f Test suite failed to run\n\n Jest encountered an unexpected token\n\n Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.\n\n Out of the box Jest supports Babel, which will be …Run Code Online (Sandbox Code Playgroud)