小编Ben*_*tes的帖子

使用 Jest 和 @testing-library/react-native 测试 React Native 项目时出现“SyntaxError:无法在模块外部使用 import 语句”错误?

每当我运行时都会出现错误npm test:

\n
 FAIL  ./App.test.js\n
Run Code Online (Sandbox Code Playgroud)\n

\xe2\x97\x8f 测试套件运行失败

\n
Jest encountered an unexpected token\n\nThis usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.\n\nBy default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".\n\nHere's what you can do:\n \xe2\x80\xa2 If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.\n \xe2\x80\xa2 To have some of your "node_modules" files …
Run Code Online (Sandbox Code Playgroud)

testing jestjs react-native react-native-testing-library

10
推荐指数
1
解决办法
2万
查看次数