【问题标题】:Jest, Typescript, ts-jest: Coverage is slightly incorrectJest、Typescript、ts-jest:覆盖范围略有不正确
【发布时间】:2017-05-02 11:47:56
【问题描述】:

我正在使用 TypeScript、Jest 和 ts-jest NPM 模块编写一个项目。

当我运行测试时,我确实得到了一些覆盖率,但 HTML 报告并不完全正确:

此外,一些函数被标记为未经测试,即使它们确实被调用了。

我的 package.json 设置如下:

{
    "jest": {
    "transform": {
      ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "testResultsProcessor": "<rootDir>/node_modules/ts-jest/coverageprocessor.js",
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/**/*.{ts,tsx}"
    ],
    "coverageReporters": [
      "html",
      "json"
    ]
  }
}

我的配置有问题吗?

【问题讨论】:

  • 你看coverage/remapped/html/index.html了吗?
  • 谢谢!您能否将其发布为回复,以便我将其标记为正确答案?

标签: node.js typescript jestjs


【解决方案1】:

更新

从 jest@20 开始,您可以传递 mapCoverage 选项并使用 coverage/lcov-report/index.html 文件。

我也一直在努力解决这个问题,但后来我注意到that line

长话短说 - 报道报告转到 coverage/remapped/html/index.html 文件。

【讨论】:

猜你喜欢
  • 2022-06-19
  • 1970-01-01
  • 2019-12-12
  • 2018-03-08
  • 2021-11-05
  • 1970-01-01
  • 2022-11-12
  • 2021-10-12
  • 2018-12-11
相关资源
最近更新 更多