Reputation: 17430
I am attempting to get Karma runner to generate cobertura formatted code coverage reports during a Jenkins build. I can get it to generate a coverage.xml file, but it does not actually have any coverage data. It appears (using LOG_DEBUG
) that the coverage preprocessor is not running.
The relevant pieces from my karma.conf.js
file are:
files = [
JASMINE,
JASMINE_ADAPTER,
'app/components/angular/angular.js',
'app/components/angular-mocks/angular-mocks.js',
'tmp/scripts/**/*.js',
'tmp/spec/**/*.js'
];
preprocessors = {
'tmp/scripts/**/*.js': 'coverage'
};
// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['dots', 'junit', 'coverage'];
junitReporter = {
outputFile: 'test-results.xml'
};
coverageReporter = {
type: 'cobertura',
dir: 'coverage/',
file: 'coverage.xml'
};
(The junit report is generating fine.)
Upvotes: 26
Views: 27040
Reputation: 17430
Apparently the karma code coverage documentation was more literal than I thought. Changing my preprocessors
configuration to
preprocessors = {
'**/tmp/scripts/**/*.js': 'coverage'
};
(notice the preceding **/
) did the trick. I am not sure why the syntax is different for the files
array and the preprocessors
object ('tmp/scripts/**/*.js'
vs. '**/tmp/scripts/**/*.js'
).
Upvotes: 28