代码之家  ›  专栏  ›  技术社区  ›  mikemaccana

如何使用当前ts笑话获取覆盖地图?

  •  0
  • mikemaccana  · 技术社区  · 4 年前

    类似 Jest, Typescript, ts-jest: Coverage is slightly incorrect -然而,答案适用于旧版本的笑话,其中 mapCoverage 选择是存在的。

    mapCoverage has now been removed 我的印象是ts jest现在应该提供开箱即用的报道。

    我遵循了 ts-jest documentation 要安装并运行ts jest:

    npm install --save-dev jest typescript ts-jest @types/jest
    npx ts-jest config:init
    npx jest --coverage --coverageDirectory='coverage'
    open coverage/lcov-report/index.ts.html
    

    但是,我可以看到,覆盖率报告生成了错误的地图:

    enter image description here

    如何使用当前ts笑话获取覆盖地图?

    我试着添加 collectCoverage: true 对我的 jest.config.js 这并没有改变输出。

    0 回复  |  直到 4 年前
        1
  •  2
  •   Gabriel    4 年前

        "compilerOptions": {
          ...
          "sourceMap": true,
    

    在你的 tsconfig.json 文件

    这为我解决了问题。

    版本:

    • 节点14.17.0
    • 打字稿:4.5.4
    • ts笑话:27.1.2
    • 笑话:27.4.5
    推荐文章