karma-runner/karma-coverage

Karma coverage exit code depends on the order of the reporters array

mcdenhoed opened this issue · 0 comments

I'm using karma and karma-coverage in a CI context, failing the CI job when a test fails or coverage is too low. I get this information from the exit code returned by karma.

However, I noticed that karma doesn't return an error for low coverage IF the text-summary reporter is placed before the html reporter.

I've made a small repo showcasing this: https://github.com/mcdenhoed/karma-test

Is this expected? I didn't find any documentation indicating that the order of the reporters array was important. I've fixed my own use-case by just changing my karma.conf.js to have

      reporters: [
        {type: "html"},
        {type: "text-summary"},
      ]

instead of

      reporters: [
        {type: "text-summary"},
        {type: "html"},
      ]

This doesn't seem to me like intended behavior, but if it is, a note in the docs about it would be nice.