使用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