jua*_*cia 5 javascript karma-runner karma-mocha karma-coverage
有关浏览器覆盖率的Karma,我需要一些帮助.我用我在这里运行的测试创建了一个repo:
https://github.com/jotaoncode/web-istanbul
测试仅在函数索引上运行.但正如您所看到的结果是100%并且仅标记绿色文件的第一行.
我已经看到伊斯坦布尔正确显示覆盖值的情况,我已经改变了测试和来源,但没有.
我也有这个业力配置:
module.exports = function(config) {
config.set({
//logLevel: 'LOG_DEBUG',
reporters: ['spec', 'coverage'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun : true,
autoWatch : false,
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
port: 9876,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [
'mocha',
'browserify'
],
files: [
'src/**/*.js',
'test/*.js'
],
// list of files to exclude
exclude: [],
preprocessors: {
'src/**/*.js': ['browserify', 'coverage'],
'test/**/*.js': ['browserify']
},
coverageReporter: {
reporters: [
{ type: 'html' },
{ type: 'text' },
{ type: 'lcovonly' }
],
instrumenterOptions: {
istanbul: {
noCompact: true
}
},
instrumenter: {
'test/**/*.js': 'istanbul'
},
includeAllSources: true
},
// enable / disable colors in the output (reporters and logs)
colors: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [
'PhantomJS2'
]
});
};
Run Code Online (Sandbox Code Playgroud)
如果您运行测试,您将看到它实际上工作正常,但覆盖率报告不正确.
经过一些研究后,我发现这个问题已经解决,如本期评论所述:
https://github.com/karma-runner/karma-coverage/issues/16
我使用了 browserify-istanbul,现在覆盖率报告工作正常:)
| 归档时间: |
|
| 查看次数: |
657 次 |
| 最近记录: |