karma-coverage icon indicating copy to clipboard operation
karma-coverage copied to clipboard

coverage only generated for the last browser (when having multiple browsers)

Open julkue opened this issue 8 years ago • 1 comments

Assuming you have the following configuration:

        coverageReporter: {
            dir: "build/coverage/",
            reporters: [{
                type: "html",
                subdir: "report-html"
            }, {
                type: "lcov",
                subdir: "report-lcov"
            }, {
                type: "text"
            }]
        }

and you are having multiple browsers configured. Then what you get is a folder build/coverage/report-html/ with e.g. directly

So you are only able to view the coverage for the last runned browser. However, when removing the subdir property from the above snippet, a folder structure like the following will be generated under build/coverage/, to view coverage for all browsers. subdir

Unfortunately I can't live without using subdir as this means that all reports will be written to the same directory.

@dignifiedquire is this a known behavior?

julkue avatar Apr 01 '16 12:04 julkue

you can use a function as the value to subdir to fix this. The browser's name is passed in, so you can use it like this:

function(browserName) { return path.join('report-html', browserName) }

and for the report-lcov reporter:

function(browserName) { return path.join('report-lcov', browserName) }

And it will output stuff into this hirarchy:

report-html/Firefox 45.0.0
report-html/PhantomJS 2.1.1
report-lcov/Firefox 45.0.0
report-lcov/PhantomJS 2.1.1

Klathmon avatar Apr 12 '16 14:04 Klathmon