问题
Here's my config file:
module.exports = function(config) {
config.set({
basePath: './',
autoWatch: true,
frameworks: ['jasmine'],
files: [
'../public_html/libs/mylib/lib.js',
'../public_html/libs/mylib/utility.js',
'../public_html/libs/mylib/config/*.js',
'../public_html/libs/mylib/enumerations.js',
'../public_html/libs/mylib/apiComm.js',
'../public_html/libs/mylib/baseObject.js',
'../public_html/libs/mylib/book.js',
'../public_html/libs/mylib/file.js',
'../public_html/libs/mylib/library.js',
'../public_html/libs/mylib/publishing.js',
'../public_html/libs/mylib/topic.js',
'../test/*Spec.js'
],
reporters: ['progress', 'coverage'],
preprocessors: {
'../public_html/libs/mylib/topic.js': ['coverage']
},
port: 9876,
colors: true,
browsers: ['Chrome'],
captureTimeout: 60000,
singleRun: false
});
};
Whenever I run karma start config/karma.config.js
it runs the unit tests and creates the coverage
folder in the correct place. However, it dumps the topic.js.html file in the same directory as topic.js. Why?
回答1:
I know this is late reply, but it might help someone else as well.
Move your config file up one folder and change the "../public_html" to "public_html"
I just got done dealing with this.
Yes you need to have the...
coverageReporter: {
type : 'html',
dir : 'coverage/'
}
...as Acosta stated, but your also instructing Istanbul when writing the report files to go up one directory and then into the public_html
folder. If the the karma.conf.js file is located in the same folder as the app and test folders then your reports should render in the proper location.
回答2:
you need to add coverageReporter,
coverageReporter: {
type : 'html',
dir : 'coverage/'
}
O you also may add a collection of reporters
coverageReporter: {
reporters: [
//{ type: 'html', dir: 'TestOutputFolder/' },
{ type: 'text-summary', dir: 'TestOutputFolder/' },
{ type: 'cobertura', dir: 'TestOutputFolder/' }
]
},
来源:https://stackoverflow.com/questions/22177345/instanbul-keeps-dumping-coverage-report-html-files-in-wrong-directory