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.)
1. Cobertura Code Coverage Report. Do nothing, just type the following Maven command to download and run the maven-cobertura-plugin automatically. Maven will generate the Cobertura code coverage report at ${project}/target/site/cobertura/index.
A karma reporter that uses the latest istanbul 1. x APIs (with full sourcemap support) to report coverage.
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'
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With