使用karma-browserify与Jasmine进行单元测试。测试正确运行,但覆盖率报告显示文件包含路径而不是源代码。您可以通过安装下列项目重现此并运行“一饮而尽单位”:karma-browserify覆盖率报告包含文件包含路径而不是源代码
https://github.com/bshack/shackstack
这里是覆盖报告内容的例子:
typeof require === "function" && require("/xxx/xxx/xxx/shackstack/app/media/script/service/utilities.js");
这里是我的karma.config:
module.exports = function(karma) {
'use strict';
karma.set({
basePath: '',
frameworks: [
'jasmine',
'browserify'
],
files: [{
pattern: 'app/media/script/service/*.js',
included: true
},
{
pattern: 'app/media/test/spec/*Spec.js',
included: true
}],
reporters: [
'progress',
'coverage'
],
preprocessors: {
'app/media/script/service/*.js': [
'browserify',
'coverage'
],
'app/media/test/spec/*Spec.js': [
'browserify'
]
},
browsers: [
//'Chrome',
//'Firefox',
//'Safari',
'PhantomJS'
],
singleRun: false,
autoWatch: false,
// browserify configuration
browserify: {
debug: true,
transform: [
'brfs',
'browserify-shim'
]
},
coverageReporter: {
type: 'html',
dir: 'app/report/istanbul/',
subdir: '.'
},
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000
});
};
有什么想法?
如果这是一个你能够重现的bug,你应该把它作为正确的回购问题。 – YPCrumble
提交了karma-browserify错误:https://github.com/nikku/karma-browserify/issues/166 – bshack