PrimosK
PrimosK

Reputation: 13918

Karma runner console - output only failed tests

This is default output of Karma test runner (with one failed test):

.
..  
...
e 28.0 (Windows): Executed 413 of 421 (1 FAILED)
e 28.0 (Windows): Executed 414 of 421 (1 FAILED)
e 28.0 (Windows): Executed 415 of 421 (1 FAILED)
e 28.0 (Windows): Executed 416 of 421 (1 FAILED)
e 28.0 (Windows): Executed 417 of 421 (1 FAILED)
e 28.0 (Windows): Executed 418 of 421 (1 FAILED)
e 28.0 (Windows): Executed 419 of 421 (1 FAILED)
e 28.0 (Windows): Executed 420 of 421 (1 FAILED)
e 28.0 (Windows): Executed 421 of 421 (1 FAILED)
e 28.0 (Windows): Executed 421 of 421 (1 FAILED) (1.74 secs / 1.091 secs)

I don't like the fact that one have to scroll all the way up to the test that failed to see an exception. This might get annoying over the time so my question is whether is it possible to somehow change the output so that only tests that failed would be reported in the console?

So in the case of one failed test I would prefer output similar to this:

Chrome 28.0 (Windows) FailedTest only should be printed to console FAILED
    ReferenceError: something is not defined
        at null.<anonymous> (c:/SuperProject/src/test/FailedTest.js:10:10)
Chrome 28.0 (Windows): Executed 71 of 421 (1 FAILED)

instead of the output above.

Upvotes: 36

Views: 23257

Answers (3)

Heather Roberts
Heather Roberts

Reputation: 2138

I found using the dots reporter and setting:

client: {
    captureConsole: false
}

in the karma config file sorted my issues out. The client.captureConsole stops any console.log() showing up.

Upvotes: 8

jaapz
jaapz

Reputation: 1009

I use a few very verbose karma reporters myself, and I had to scroll up the terminal to find my errors too. This annoyed me to no end, so I wrote a reporter that just reports the failed tests. It works nice in combination with 'karma-spec-reporter'.

https://github.com/jaapz/karma-failed-reporter

Upvotes: 6

Steve Jansen
Steve Jansen

Reputation: 9494

Looking at http://karma-runner.github.io/0.10/config/configuration-file.html

Have you tried setting the config to use an empty reporters array? Karma v0.10 defaults to a reporters config of ['progress'], which is likely causing your verbose output.

You might like the 'dots' reporter. You can try it on the CLI using

karma start yourconfig.js  --reporters dots

Upvotes: 52

Related Questions