小编Ros*_*tty的帖子

React 中的 axios “无法在模块外部使用 import 语句”

我在 React 应用程序中使用 axios 以及 MUI 进行样式设置。我在开发时没有错误,但现在当我开始使用我的 React 应用程序编写测试时react testing libraryjest我收到 axios 模块错误,如下所示。我查阅了很多文章,很可能是因为 axios 将模块类型从 CommonJS 更改为 ECMAScript。我尝试在 React 中修改Vue.js 的这个解决方案,但我做不到。

\n
 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)

node.js reactjs jestjs react-testing-library

0
推荐指数
2
解决办法
5142
查看次数

标签 统计

jestjs ×1

node.js ×1

react-testing-library ×1

reactjs ×1