How to get better test reports in the console?

blockloop picture blockloop · Jun 25, 2013 · Viewed 24k times · Source

I have a fairly simple karma.config.js file

basePath = '../';


files = [
  JASMINE,
  JASMINE_ADAPTER,
  'js/lib/angular*.js',
  'test/lib/angular/angular-mocks.js',
  'js/**/*.js',
  'test/unit/**/*.js'
];

autoWatch = true;
browsers = ['PhantomJS'];


When I run karma start config/karma.conf.js --single-run I'm getting the following output

$ karma start config/karma.conf.js --single-run
[2013-06-24 23:47:08.750] [DEBUG] config - autoWatch set to false, because of singleRun
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9 (Mac)]: Connected on socket id LwMoWxzIbSUuBsvIqB_m
PhantomJS 1.9 (Mac): Executed 6 of 6 SUCCESS (0.073 secs / 0.02 secs)

I've been searching for something to tell me how to get the output of the tests that get logged (e.g. SUCCESS Unit: services myService should behave)

The only way I can see the output of the tests is to open Chrome and click 'Debug', then show the developer tools console. I want the messages to be logged out to the terminal, but I cannot figure out how to get this working.

Answer

blockloop picture blockloop · Jun 26, 2013

Fixed by installing the karma-spec-reporter

npm install karma-spec-reporter --save-dev

and adding this my karma.config.js

reporters: ['spec'],

According to karma documentation

By default, Karma loads all NPM modules that are siblings to it and their name matches karma-*.

but some users have had to add the following to their config

plugins: ['karma-spec-reporter']