我正在使用Karma編寫JS單元測試用例和伊斯坦布爾以獲取覆蓋率報告。 我karma.conf.js文件如下 -我想在karma.conf.js中使用多個覆蓋率報告類型
// karma.conf.js
module.exports = function(config) {
config.set({
files: [
'test/**/*.js'
],
// coverage reporter generates the coverage
reporters: ['progress', 'coverage'],
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'test/**/*.js': ['coverage']
},
// optionally, configure the reporter
coverageReporter: {
type : 'html',
dir : 'coverage/'
}
});
};
這裏裏面coverageReporter我想用型 'HTML' 和 'LCOV'。要做到這一點,我如下改變了它 -
coverageReporter:{ 類型: 'HTML', 'LCOV', DIR: '報道/' }
然後我執行karma start karma.conf.js
但得到以下例外 - -
C:\abc\npm-1.4.9>karma start karma.conf.js
05 05 2017 16:57:00.369:ERROR [config]: Invalid config file!
C:\abc\npm-1.4.9\karma.conf.js:45
type : 'html','lcov',
^
SyntaxError: Unexpected token ,
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
任何幫助,非常感謝。
這個工作,但是有一個副作用。我在karma.conf.js(Chrome和PhantomJs)中提到了兩個瀏覽器,因此通常會分別爲每個瀏覽器生成報告,但上面的配置會忽略瀏覽器配置。有關這個的任何想法? - –