Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma command line doesn't display test results after adding code coverage

Tags:

karma-runner

I'm using Karma to do some unit testing and to generate code coverage stats. When i run the test from the command line without the code coverage settings in the karma config i can see the test results in the command line. i.e

Executed 3 of 3 SUCCESS (0.465 secs / 0.048 secs)

When I add the code coverage settings to the config and run the test, the coverage files get generated but i do not see the test results in the command line.

My config is:

basePath = '../';

files = [
    JASMINE,
    JASMINE_ADAPTER,
    'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js',
    'app/lib/angular/angular.js',
    'app/lib/angular/angular-scenario.js',
    'test/lib/angular/angular-mocks.js',
    'app.js',      // include app first as other module hang off it
    'public/javascript/**/*.js',
    'test/unit/**/*.js'
];

/* code coverage settings */
preprocessors = {
    '**/public/javascript/**/*.js': 'coverage'
};

reporters = ['coverage']; 
/* end code coverage settings */

autoWatch = true;

browsers = ['Chrome'];

junitReporter = {
    outputFile: 'test_out/unit.xml',
    suite: 'unit'
};

I could just create separate scripts to generate the code coverage and run the tests, and my be better off doing that in terms of speed etc, but I wanted to know if I could do them together, and if so have I miss configured something?

like image 343
Dave Avatar asked Oct 04 '22 08:10

Dave


1 Answers

When you added the "coverage" reporter in your config it seems you removed the "progress" reporter that used to be there by default.

Just change the reporters part of your config to:reporters = ['coverage','progress'] instead of reporters = ['coverage']

like image 83
Metareven Avatar answered Oct 06 '22 00:10

Metareven