Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

karma test runner detailed test report in console

Tags:

karma-runner

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.

like image 781
Amitava Avatar asked Jun 15 '13 04:06

Amitava


People also ask

What is karma test runner?

Karma is a test runner for JavaScript that runs on Node. js. It is very well suited to testing AngularJS or any other JavaScript projects. Using Karma to run tests using one of many popular JavaScript testing suites (Jasmine, Mocha, QUnit, etc.)

How do I run a karma test on my browser?

You need to run it with singleRun = false in karma. conf. js and then click the button on the top corner that says "DEBUG". Then you should see the output and it won't disappear or close.

Is jest faster than karma?

Comparing test execution time, I found that Jest runs unit tests at 2x to 3x the speed of Karma. This can be drastic as your project becomes larger and the amount of test cases skyrocket.


Video Answer


1 Answers

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'] 
like image 86
Carles Barrobés Avatar answered Oct 15 '22 04:10

Carles Barrobés