用React Native开玩笑

运动

我在尝试运行测试用例代码时遇到错误。升级0.40之前一切正常。现在是0.42,我所有的测试用例都停止工作并在出现错误后出现错误。

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React, { Component, Children, PropTypes } from 'react';
                                                                                             ^^^^^^
    SyntaxError: Unexpected token import

      at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:320:12)
      at Object.<anonymous> (node_modules/react-native-root-siblings/lib/AppRegistryInjection.js:3:22)
      at Object.<anonymous> (node_modules/react-native-root-siblings/lib/SiblingsManager.js:3:27)

这是我的.babelrc代码

{
    "presets": [
        "react-native"
    ],
    "plugins": [
        "transform-decorators-legacy"
    ]
}

我没有得到什么问题。

运动

我有解决办法

"jest": {
        "preset": "react-native",
        "transformIgnorePatterns": [
          "node_modules"
        ],
        "coveragePathIgnorePatterns": [
          "node_modules"
        ],
        "modulePathIgnorePatterns": [
          "node_modules"
        ]
      },

在我devDependencies我加入"react-addons-test-utils""react-dom"

"devDependencies": {
    "babel-core": "^6.17.0",
    "babel-eslint": "^7.2.1",
    "babel-jest": "^19.0.0",
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-decorators": "^6.13.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2017": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-react-native": "^1.9.1",
    "babel-preset-stage-0": "^6.16.0",
    "enzyme": "^2.8.0",
    "jest": "^19.0.2",
    "npm": "^4.4.4",
    "react-addons-test-utils": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-test-renderer": "^15.4.2"
}

多数民众赞成在解决所有问题。

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

开玩笑的React示例

用道具开玩笑的快照

在React Native项目中开玩笑进行单元测试(“ Not a function”错误)

在Android的React Native中使用排毒+开玩笑时出现“ ReferenceError:设备未定义”

如何在React-Native中以开玩笑的方式模拟Picker和Picker.Item?

开玩笑地测试使用NavigationEvents的React-native组件引发错误

带有打字稿的react-native-vector-icons / MaterialIcons开玩笑快照测试错误

用create-react-app开玩笑-意外的令牌错误

在React-Native项目中开玩笑。如何将重复的模块列入黑名单或删除?

用React和Typescript开玩笑的嘲笑:模拟ES6类依赖

为什么用React测试库无法在测试中执行开玩笑的模拟功能?

用 Enzyme 开玩笑,为什么在我的 React 组件测试中没有触发“toHaveBeenCalled”?

用NestJS和异步功能开玩笑

用 Typescript 开玩笑地模拟一个库

如何开玩笑地用axios测试异步动作?

用开玩笑的存根函数来测试内部错误

开玩笑-如何测试react方法的输出是否正确?

React Hooks 开玩笑测试 - 方法不是函数

在React + Typescript + Webpack项目中开玩笑配置错误

开玩笑的意外标识符:React

开玩笑 react-testing-library 错误符号不是函数

开玩笑-添加'</React.Fragment>'后,快照测试失败

使用 react-intersection-observer 开玩笑测试反应组件

基本的create-react-app开玩笑测试说明

用Luxon开玩笑的单元测试:如何模拟.setZone('local')

NodeJs在执行测试用例时用开玩笑的错误表达MongoDB

如何开玩笑地用axios测试异步动作?- 第2部分

开玩笑的测试:从'Link.react.js'中找不到模块'../Link.react'

开玩笑的酶浅测试不能呈现React组件的所有元素