How to setup Karma coverage reporter with multiple types?
Asked Answered
G

3

6

I want to get cobertura and html output from the karma coverage reporter. At the moment I have to run the tests twice. One time with this configuration:

reporters: ['progress', 'coverage']
coverageReporter: { type : 'cobertura', dir : 'coverage/', file: 'cobertura.xml' }

The other time with:

coverageReporter: {type : 'html'....

Is there a way to do this in one run?

Gwenny answered 25/9, 2014 at 12:0 Comment(0)
P
14
coverageReporter: {
  reporters: [
    { type: 'html', dir: '/' },
    { type: 'cobertura', dir: '...' }
  ]
}

Should work

Presentationism answered 25/9, 2014 at 14:13 Comment(0)
B
1
coverageReporter: {
  dir: 'coverage-report',
  reporters: [{
    type: 'html',
    subdir: 'report-html',
  }, {
    type: 'lcov',
    subdir: 'report-lcov',
  }]
}
Bondage answered 30/6, 2021 at 5:56 Comment(1)
While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value.Fadge
F
0

You can find karma-coverage docs https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md

But the answer in short, how to use multiple reporters is, by providing array of options:

coverageReporter: {  reporters:[
{type: 'html', dir:'coverage/'},
{type: 'teamcity'},
{type: 'text-summary'}],}
Fitted answered 18/3, 2024 at 9:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.