2

我正在使用nightwatch基于 selenium 的测试,但是当我使用 时nyc nightwatch,它只报告测试代码及其 100% 的覆盖率。这是我现在的主要障碍。我如何获得保险?基本上,我希望最终将其作为 Jenkins CI 的报告。

此外,我还想用我正在使用的 UT 进行测试jest。通常,"test": "jest --coverage"将正确列出所有测试代码的覆盖率。所以当我给它时nyc npm run test,它会给我同样的覆盖面,这很好。但是当我只用 运行时nyc jest,它会返回 100% 的覆盖率jest.config.js!!

我没有mocha或之grunt类的。

4

1 回答 1

1

由于 jest 在后台使用 nyc,因此没有理由将它们一起使用。您可以使用标志调用 jest--coverage并告诉它在您的配置中使用哪些报告,如配置中所定义:

  "jest": {
    "collectCoverage": true,
    "collectCoverageFrom": [
      "**/*.{js,jsx}",
      "!**/node_modules/**",
      "!**/vendor/**"
    ],
    "coverageReporters": [
      "text",
      "cobertura"
    ],
    "reporters": [
      "default",
      "jest-junit"
    ]
  }

https://jestjs.io/docs/en/configuration#coveragereporters-arraystring

于 2020-02-14T13:58:32.610 回答