2016-12-16 109 views
9

我正在使用TypeScript,Jest和ts-jest NPM模块撰写项目。Jest,Typescript,ts-jest:覆盖率稍微不正确

当我运行我的测试,我得到报道的一些量,但是HTML报告是不完全正确:

Code coverage issues

此外,一些功能被标记为未经检验的,即使他们肯定被称为。

我的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" 
    ] 
    } 
} 

什么毛病我的配置?

+1

你看过'coverage/remapped/html/index.html'吗? –

+0

谢谢!你可以发布这个作为回应,以便我可以将此标记为正确答案吗? – Rick

回答

4

UPDATE

从玩笑@ 20日起,您可以通过mapCoverage选项,并使用coverage/lcov-report/index.html文件。

OLD

我也一直在努力解决这个问题,但后来我发现that line

长话短说 - 覆盖报告去coverage/remapped/html/index.html文件。

+0

有什么方法可以在控制台中使用重新映射的输出,而不是“稍微偏离”一个? –

+1

@JarrodMosen目前不可能,请参阅https://github.com/kulshekhar/ts-jest/issues/42#issuecomment-256792842 –