Html – Generating a HTML test-report with Karma

htmljasminejunitkarma-runnerunit testing

My team currently use karma as the testrunner for our unit tests. We are now trying to figure out if there is a way to get karma to generate a html-file containing the test-results.

What we hope to achieve by this is that we can have karma running on one of our servers and that whenever we upload new code or tests, our tests will be re-run on a myriad of different browsers. The html-files generated by these tests could then be displayed by anyone wanting to see whether or not all tests still go green on all the different desktop and mobile browsers tested.

Currently I've looked into using Karma's junit reporter and then post-process these files with ant to get HTML-files, but we're currently using Grunt as our building tool and I'd prefer not having to include ant to the mix.

Also, is there some sort of guide to creating Karma reporters if we decide that creating one would be the best way to solve our issue?

Best Answer

I've written a simple HTML reporter which does the job:

https://github.com/matthias-schuetz/karma-htmlfile-reporter

Just add it to your karma.conf.js and it will produce an HTML file with test results.