2016-12-16 111 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 –