2016-12-01 51 views
1

我正在使用nyc來生成代碼覆蓋率報告。我爲我的測試使用不同的級別。我如何合併不同級別的報告?如何設置不同測試級別的測試代碼覆蓋率?

有我我的package.json

"scripts": { 
    "test": "npm run test:unit && npm run test:component", 
    "test:component": "nyc mocha ./test/component", 
    "test:unit": "nyc mocha ./test/unit" 
}, 
"nyc":  { 
    "extension": [ 
    ".ts" 
    ], 
    "cache": true, 
    "reporter": [ 
    "lcov", 
    "text-summary" 
    ] 
} 
+0

您可以使用託管解決方案通過Codecov標誌完成此操作:http://docs.codecov.io/docs/flags讓我知道您是否有疑問。 –

回答

1

的一部分,您可以使用nycmocha的序列來達到這種效果。

隨着npm scripts這將是這樣的:

{ 
    "scripts": { 
     "coverage" : "nyc npm run test", 
     "test": "npm run test:unit && npm run test:component", 
     "test:component": "mocha ./test/component", 
     "test:unit": "mocha ./test/unit" 
    }, 
    "nyc": { ... } 
} 

主要思想,背後nyc是,它需要所有的配置和手段他們定義的源文件。

然後它在修改了require的插裝之後運行命令,因此您從nyc中運行的每個命令都將具有檢測文件,因爲它是源代碼。

相關問題