小编Cor*_*lie的帖子

使用 babel、nyc 和 istanbul 插件从 Cypress 获取代码覆盖率?

对于 React/Redux 项目,我使用 Cypress 来测试 UI。我需要从这些测试中获取代码覆盖率,以便在声纳中获得详细信息(但那是另一个故事了)。

所以我开始阅读 Cypress 的文档:https://docs.cypress.io/guides/tooling/code-coverage.html

我按照说明找到了不同的插件,但没有任何作用。运行赛普拉斯测试后,我没有覆盖结果,当我尝试使用转译中的检测代码运行服务器并尝试获取window.__coverage__它的undefined.

这是我的配置。

我的 devDep 和 NYC conf 在package.json中:

"devDependencies": {
    "@cypress/code-coverage": "^1.8.0",
    "babel-cli": "^6.26.0",
    "babel-plugin-istanbul": "^5.2.0",
    "babel-plugin-react-intl": "^2.4.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-react-app": "^3.1.2",
    "cross-env": "^5.2.0",
    "cypress": "3.1.0",
    "istanbul-lib-coverage": "^2.0.5",
    "jest-junit-reporter": "^1.1.0",
    "junit": "^1.4.9",
    "nyc": "^14.1.1",
    "react-test-renderer": "^16.3.0"
     [...]
},
"scripts": {
    "start": "react-scripts start",
    [...]
    "test:unit:local": "react-scripts test --env=jsdom .*_test.js",
    "test:unit": "npm run test:unit:local -- --ci --coverage --testResultsProcessor ./node_modules/jest-junit-reporter",
    "test:integ:local": "cypress run --reporter junit",
    "test:integ": …
Run Code Online (Sandbox Code Playgroud)

testing istanbul reactjs babeljs cypress

8
推荐指数
1
解决办法
6584
查看次数

标签 统计

babeljs ×1

cypress ×1

istanbul ×1

reactjs ×1

testing ×1