测试套件无法运行。引用错误:未定义__DEV__

时间:2017-05-19 06:17:58

标签: unit-testing react-native jestjs

请检查我的Package.json,因为我无法找到它的错误。 Stackoverflow中的先前问题没有帮助我

React Native - __DEV__ is not defined

ReferenceError: Can't find variable: __DEV__ enter link description here

{
  "name": "mobility1",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "mocha": "BABEL_ENV=mocha mocha --require mocha-setup.js --compilers js:babel-core/register --recursive __tests__/mocha",
    "mocha:watch": "./mocha.runner.sh",
    "test": "jest",
    "build:android": "node node_modules/react-native/local-cli/cli.js bundle --entry-file='index.android.js' --bundle-output='./android/app/src/main/assets/index.android.bundle' --dev=false --platform='android' --assets-dest='./android/app/src/main/res/'",
    "build:ios": "node node_modules/react-native/local-cli/cli.js bundle --entry-file='index.ios.js' --bundle-output='./ios/ShootstaCue/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"
  },
  "dependencies": {
    "react": "~15.4.0-rc.4",
    "react-native": "0.40.0",
    "react-native-animatable": "^1.1.0",
    "react-native-camera": "^0.6.0",
    "react-native-drawer": "^2.3.0",
    "react-native-linear-gradient": "^2.0.0",
    "react-native-scrollable-tab-view": "^0.7.2",
    "react-native-vector-icons": "^4.0.0",
    "react-redux": "^5.0.4",
    "redux": "^3.6.0",
    "redux-logger": "^2.7.4",
    "redux-observable": "^0.14.1",
    "redux-persist": "^4.1.0",
    "redux-thunk": "^2.2.0",
    "reselect": "^2.5.4",
    "rxjs": "^5.2.0"
  },
  "devDependencies": {
    "babel-jest": "^20.0.3",
    "babel-preset-react-native": "^1.9.2",
    "chai": "^3.5.0",
    "enzyme": "^2.8.2",
    "jest": "^20.0.3",
    "jest-react-native": "^18.0.0",
    "mocha": "^3.4.1",
    "react-addons-test-utils": "15.4.2",
    "react-test-renderer": "^15.4.2",
    "regenerator-runtime": "^0.10.5",
    "remote-redux-devtools": "^0.5.7"
  },
  "jest": {

    "haste": {
      "defaultPlatform": "ios",
      "platforms": [
        "ios",
        "android"
      ],
      "providesModuleNodeModules": [
        "react-native"
      ]
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我有同样的问题,改变了jest:{....}到

 "jest": {
     "preset": "react-native"
  },