使用快照Jest测试配置来响应本机EXPO应用程序

时间:2019-01-30 05:25:54

标签: react-native jestjs babel expo snapshot

我无法在React native expo app中进行Jest快照测试。根据节点模块的设置和配置,我会遇到各种错误。
例如:
* SyntaxError: Unexpected identifier import ...或大约import React来自另一个文件,
* jest encountered an unexpected token import
*与script_transformer有关的错误。

这是我的package.json

{
  "name": "empty-project-template",
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "lint": "eslint .",
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject",
    "test": "node_modules/.bin/jest"
  },
  "dependencies": {
    "expo": "^31.0.0",
    "moment": "^2.22.2",
    "pouchdb-react-native": "^6.4.1",
    "prop-types": "^15.6.2",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
    "react-native-easy-toast": "^1.1.0",
    "react-native-range-datepicker": "^1.8.2",
    "react-navigation": "^2.18.2",
    "react-redux": "^5.1.1",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.1",
    "babel-plugin-syntax-class-properties": "^6.13.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "eslint": "^5.9.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-react": "^7.11.1",
    "jest-expo": "^31.0.0",
    "react-test-renderer": "^16.7.0"
  },
  "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!(pouchdb-react-native|pouchdb-adapter-asyncstorage))"
    ]
  }
}

有人可以将我指向具有Jest快照测试的React-native Expo应用程序的工作仓库。

1 个答案:

答案 0 :(得分:1)