Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Karma runner code coverage?

Tags:

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.)

like image 854
Noah Freitas Avatar asked Mar 26 '13 22:03

Noah Freitas


People also ask

How do you use the cobertura code coverage tool?

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.

What is karma coverage Istanbul reporter?

A karma reporter that uses the latest istanbul 1. x APIs (with full sourcemap support) to report coverage.


1 Answers

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').

like image 56
Noah Freitas Avatar answered Sep 18 '22 19:09

Noah Freitas