How can I get a list of passing tests from karma runner suite?

Amit Erandole picture Amit Erandole · Jun 3, 2013 · Viewed 24.7k times · Source

When I run karma on my webapp, I only get generic messages like tests passed - is there a way to get a list of passing tests? How do I get more verbose output?

I cannot find this anywhere in the documentation.

Answer

benshope picture benshope · Feb 10, 2015

I know how this can be done!

Karma's terminal output comes from objects called Reporters. Karma ships with some built-in Reporters (they can be found in karma/lib/reporters). Karma is also able to use custom Reporters.

You can specify which reporters are used in your project's karma.config.js file.

For example, the 'dots' reporter just prints a dot when each test passes:

reporters: ['dots'],

The 'progress' reporter prints more than dots:

reporters: ['progress'],

The custom reporter karma-spec-reporter prints the name of each test when the test succeeds or fails (but not much else):

reporters: ['spec'],

You may want to roll your own reporter, since karma-junit-reporter, karma-spec-reporter, and the included reporters may not meet your needs.

I am guessing that customizing karma-spec-reporter is the best option in this case, since it already prints a line when a test succeeds.

If you are looking for something even more simple to work from, here is a custom reporter that I built. It reports passing and failing tests with no terminal colors.