Jest、Typescript、ts-jest:覆盖范围略微不正确

Jest, Typescript, ts-jest: Coverage is slightly incorrect

我正在使用 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"
    ]
  }
}

我的配置有问题吗?

更新

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

我也一直在为这个问题苦苦挣扎,但后来我注意到 that line

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