意外的导入令牌-使用Jest测试React Native

马特·阿夫特

尝试用玩笑来测试我的react-native应用程序时出现奇怪的导入错误。我安装了babel-jest,babel-preset-react-native,jest,jest-react-native和react-test-render都已安装,但是在运行npm test时收到此错误消息。

●测试套件无法运行

/Users/maftalion/www/stars20/kiosk/node_modules/native-base/index.js:4
import Drawer from './Components/vendor/react-native-drawer';
^^^^^^
**SyntaxError: Unexpected token import**

  at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:316:10)
  at Object.<anonymous> (src/routes/Identification.js:3:17)
  at Object.<anonymous> (src/routes/router.js:4:21)

测试套件:1个失败,1个通过,总共2个测试:1个通过,总共1个快照:1个通过,总共1个时间:1.011s

马特·阿夫特

弄清楚了,基本上将所有使用es6语法的节点模块都放在transformIgnorePatterns中。

"transformIgnorePatterns": [
   "node_modules/(?!react-native|native-base|react-clone-referenced-element)"
],

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

[React-Native] [Jest] SyntaxError:意外的令牌导入

React Native:意外的令牌

用Jest测试React Native Application-Jest遇到意外令牌

使用Jest进行测试Vue失败,Jest遇到意外的令牌,SyntaxError:意外的令牌导入

React Native fetch,意外的令牌

React Native Navigator意外令牌

React Native 与 Redux - 意外令牌

React Native - 意外令牌,预期“;”

React Jest-意外的令牌导入

SyntaxError:使用Jest意外导入令牌

Jest遇到了带有react-native的意外令牌

如何测试使用Jest导入自定义本机模块的React Native组件?

运行Jest测试时出现意外的令牌“导入”错误?

React Native:意外令牌转换错误(

语法错误意外令牌,React Native

React Native:意外的令牌,预期为“,”

react-native:解析错误:意外的令牌<

Jest中的动态导入产生:SyntaxError:意外的令牌导入

React-native-modal-使用TransformIgnorePatterns玩笑的意外令牌

在React Native + Typescript应用程序上运行Jest时出错(Jest遇到意外令牌)

React Jest测试无法与ts-jest一起运行-导入文件上出现意外令牌

Jest 在 Typescript 中导入 lodash 函数时遇到意外的令牌

Jest遇到意外令牌-导入(Angular CLI 6)

React Native渲染功能给出错误:意外令牌

如何在React-Native / Metro中调试“意外令牌'。'”?

React Native捆绑:SyntaxError:意外令牌:运算符(*)

React Native构造函数:意外的令牌,预期为“;”

i18n React-Native意外令牌';'

React native:位置0的JSON中的意外令牌