【问题标题】:Jest-cli errorsJest-cli 错误
【发布时间】:2017-08-23 14:02:03
【问题描述】:

我在运行测试中有两个错误。我没有解决它:/

节点:v6.11.2
Npm:v3.10.10

第一个错误是无法读取属性“对象”。为空

TypeError: Cannot read property 'Object.<anonymous>' of null
    at Runtime._execModule (/home/dby/test/jesttest/node_modules/jest-runtime/build/index.js:510:72)
    at Runtime.requireModule (/home/dby/test/jesttest/node_modules/jest-runtime/build/index.js:329:14)
    at Runtime.requireModuleOrMock (/home/dby/test/jesttest/node_modules/jest-runtime/build/index.js:405:19)
    at Function.bezier (/home/dby/test/jesttest/node_modules/react-native/Libraries/Animated/src/Easing.js:228:13)
    at ease (/home/dby/test/jesttest/node_modules/react-native/Libraries/Animated/src/Easing.js:94:14)
    at TimingAnimation._easing (/home/dby/test/jesttest/node_modules/react-native/Libraries/Animated/src/Easing.js:262:10)
    at TimingAnimation.onUpdate (/home/dby/test/jesttest/node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:338:22)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

package.json

  "dependencies": {
    "native-base": "^2.3.1",
    "react": "16.0.0-alpha.12",
    "react-native": "0.47.2",
    "react-native-vector-icons": "^4.3.0",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0"
  },
"devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-eslint": "^7.2.3",
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "^3.0.1",
    "enzyme": "^2.9.1",
    "jest": "20.0.4",
    "jest-react-native": "^18.0.0",
    "react-addons-test-utils": "^15.6.0",
    "react-dom": "^15.6.1",
    "react-test-renderer": "^16.0.0-beta.5",
    "redux-mock-store": "^1.2.3"
  },
  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "/node_modules/(?!native-base)/",

    ]
  }

当我不使用 jest --no-cache 时,抛出这个错误
第二个错误

/usr/lib/node_modules/jest-cli/node_modules/jest-runtime/build/index.js:510
    const wrapper = this._environment.runScript(transformedFile.script)[ ^

【问题讨论】:

    标签: testing react-native jestjs


    【解决方案1】:

    也许试试类似的东西。

        "jest": {
        "verbose": true,
        "coverageDirectory": "./coverage",
        "coverageThreshold": {
            "global": {
                "branches": 40,
                "functions": 0,
                "lines": 33,
                "statements": 25
            }
        }
    }
    

    并将其添加到脚本中。

    "test": "node ./node_modules/jest/bin/jest --coverage",
    

    【讨论】:

    • 感谢您的回答。它不相关的报道:/不起作用:/
    • 你应该可以使用我发布的一些结构。不确定 react-native 是否与 Jest 不同。您是否包含了开玩笑所需的所有节点模块?
    • 我不知道:/我在互联网上找到模块:/
    猜你喜欢
    • 2021-02-15
    • 2021-03-18
    • 2021-06-23
    • 2018-03-15
    • 1970-01-01
    • 2018-09-10
    • 2019-07-22
    • 1970-01-01
    相关资源
    最近更新 更多