Possible to report coverage to console and html?

1,445 views
Skip to first unread message

Allen Bierbaum

unread,
Jun 25, 2013, 3:21:52 PM6/25/13
to karma...@googlegroups.com
I am looking into using Karma for one of our projects and have been evaluating it.

So far I love the integration but ran into a problem with the coverage reporting.  Namely I can get the text summary to show in the console which is great for showing users quick feedback, but when I do that I can't find a way to also generate the HTML report so people can go see the details.


Is there a way to configure coverage so that it both writes a summary to the console and creates a full html report?

On a related question would it be possible to have the report generator for the full HTML report print a full file path to the report on the console?  That would make it much easier for developers to click on the link to get to the full details to track down places they want to improve coverage.

Thanks,
Allen

Vojta Jína

unread,
Jun 26, 2013, 6:34:56 PM6/26/13
to karma...@googlegroups.com
Did you see http://karma-runner.github.io/0.8/config/coverage.html ? Make sure you configure the reporter to generate html output and you should be fine.

Btw, I recommend only running coverage as a separate build not during development, as it slows down and makes debugging harder (each file has to be preprocessed).

V.


--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Allen Bierbaum

unread,
Jun 26, 2013, 10:18:35 PM6/26/13
to karma...@googlegroups.com
On Wed, Jun 26, 2013 at 5:34 PM, Vojta Jína <vojta...@gmail.com> wrote:
Did you see http://karma-runner.github.io/0.8/config/coverage.html ? Make sure you configure the reporter to generate html output and you should be fine.


I was able to get HTML output working, but not HTML and text summary at the same time.  I forked karma-coverage and created a pull request that allows multiple reporters to be configured for the same run.  See: https://github.com/karma-runner/karma-coverage/pull/6

With this change I can get HTML and text summary output together.
 
Btw, I recommend only running coverage as a separate build not during development, as it slows down and makes debugging harder (each file has to be preprocessed).

Understood.  I came up with a workaround for our grunt-basd build.  I am not sure if it is a good idea or not, but what I did is to create two testing tasks.  The first one runs unit tests normally, then the second one will run coverage using phantomjs in 'singleRun' mode to generate coverage information (summary text and generated HTML to see details and track down areas to further test).  This lets the tests run normally and support debugging normal unit tests to run for debugging 

If anyone is interested in the details, there is a simple example here: https://github.com/abierbaum/test_karma/blob/dev/karma_canary/Gruntfile.js

It seems to work pretty well although sometimes I end up with several phantomjs processes in the background if I use PhantomJS as the browser for the karma:unit background process.  When I switch this over to Chrome it seems to work a bit better.  If anyone has a better idea how to do this I am open to suggestions.

Anyway, thanks again for the great tool.  Looking at some of the new features in 9.x I am excited to see what people can do in the future.

-Allen



V.


On Tue, Jun 25, 2013 at 12:21 PM, Allen Bierbaum <abie...@gmail.com> wrote:
I am looking into using Karma for one of our projects and have been evaluating it.

So far I love the integration but ran into a problem with the coverage reporting.  Namely I can get the text summary to show in the console which is great for showing users quick feedback, but when I do that I can't find a way to also generate the HTML report so people can go see the details.


Is there a way to configure coverage so that it both writes a summary to the console and creates a full html report?

On a related question would it be possible to have the report generator for the full HTML report print a full file path to the report on the console?  That would make it much easier for developers to click on the link to get to the full details to track down places they want to improve coverage.

Thanks,
Allen

--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.

To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to a topic in the Google Groups "karma-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/karma-users/T5JhAiNKXek/unsubscribe.
To unsubscribe from this group and all its topics, send an email to karma-users...@googlegroups.com.

Vojta Jína

unread,
Jun 27, 2013, 3:35:04 AM6/27/13
to karma...@googlegroups.com
Great, I will look into your PR!
Reply all
Reply to author
Forward
0 new messages