karma test runner detailed test report in console

Karma Runner

Karma Runner Problem Overview


I just started with unit test my angular app with karma. Everything working as expected

> Chrome 26.0 (Windows): Executed 1 of 1
> Chrome 26.0 (Windows): Executed 1 of 1 SUCCESS (0.878 secs / 0.112 secs)

However, is there any way to output more info about the result of the test. For example, Suite and test names it is executing and their result. I've read few tutorials where Jasmine test result outputs in browser. I'm wondering it can be achieved in karma too.

Karma Runner Solutions


Solution 1 - Karma Runner

I was looking for something similar, and found this: https://github.com/usrz/javascript-karma-verbose-reporter. Generates this kind of output:

$ karma start --reporters=verbose

Suites and tests results:

 - the app.router.config module :
   * contains a router property : ok
   * configures the router title : ok
   * should have a login route : ok
 - the organization module :
   * contains a state property : ok
   * should have a streams route after configuration : ok
   * when activated, should set state based on organization in route : ok
 - the streams module :
   * points to state : ok
   * loads organization streams upon activation : ok
   * loads organization streams via API : ok

Browser results:

 - PhantomJS 1.9.8 (Mac OS X 0.0.0): 9 tests
   - 9 ok

To make this a default option, you can add this to your karma config, e.g.:

reporters: ['verbose', 'junit']

Solution 2 - Karma Runner

I've just finished a HTML reporter for Karma, so you could add it to the reporters. You will get some additional information as in the console but you can go with "singleRun = true" in your configuration. The plugin is located here:

https://npmjs.org/package/karma-htmlfile-reporter

After installing the plugin via "npm install karma-htmlfile-reporter -g", you just need to add some lines to your karma.conf.js:

reporters: ['progress', 'html'],

htmlReporter: {
  outputFile: 'tests/units.html'
},

plugins: [
  // ... your other plugins here
  'karma-htmlfile-reporter'
]

Now, after running your Karma tests, the plugin will produce a styled HTML file you can view in your browser.

Solution 3 - Karma Runner

As Ilja said, I wouldn't know what kind of information you'd want from successful tests. You could however open the debug-page if you're running the tests in a browser: Probably at http://localhost:9876/debug.html. All Unit-tests get logged to console there.

Solution 4 - Karma Runner

Following from @Carles Barrobés's answer. The original question was talking about angular applications. So I thought I would list the steps to get this to work with ng test

Install verbose reporter:

npm install --save-dev karma-verbose-reporter

Update your karma.conf.js file to include the following:

module.exports = function (config) {
  config.set({
    plugins: [
      require('karma-verbose-reporter')
    ],
    reporters: ['verbose']
  });
};

Note, I have only included settings relevant to reporting, of course, leave your other settings in the config file as is.

Now you can run ng test to get verbose output

Solution 5 - Karma Runner

I think this Documention may help you to config its output in console.

As is described:

reporters: ['progress', 'junit']
  • The 'progress' is for output in console
  • The 'junit' is a karma plugin for output in outside files. :)

Solution 6 - Karma Runner

I got what you want. You want detailed report in console itself.

With 'progress', it only prints like "this many success out of this. but not detailed report."

example : Executed 1 of 1 SUCCESS (0.878 secs / 0.112 secs)

reporters: ['progress']

For printing detail report in console itself use "mocha" report which prints details execution in console the way "kjhtml" does in broswer.

reporters: ['mocha']

mocha prints in console itself, used with phantomjs browser and chrome headless browser

You have to have plugin for the same. follow link for the same

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmitavaView Question on Stackoverflow
Solution 1 - Karma RunnerCarles BarrobésView Answer on Stackoverflow
Solution 2 - Karma RunnerMatthiasView Answer on Stackoverflow
Solution 3 - Karma RunnerDJ_HOEKView Answer on Stackoverflow
Solution 4 - Karma RunnerIan JamiesonView Answer on Stackoverflow
Solution 5 - Karma RunnermicfanView Answer on Stackoverflow
Solution 6 - Karma Runnervipul patelView Answer on Stackoverflow