sshev / karma-remap-coverage

Karma reporter that maps coverage to original non transpiled code (TypeScript, ES6/7, etc)
MIT License
35 stars 4 forks source link

Implement coverage checks, just like karma-coverage #4

Open remcohaszing opened 8 years ago

remcohaszing commented 8 years ago

karma-coverage allows to specify some coverage checks, so karma fails if the minimal coverage isn't achieved.

Could you implement that for this plugin as well?

sshev commented 8 years ago

aim of karma-remap-coverage reporter is just to remap coverage to original files it's based on karma-coverage so you are free to configure coverage checks, for example:

coverageReporter: {
  check: {
    global: {
      lines: 80
    }
  },
  type: 'in-memory'
},
remapCoverageReporter: {
  html: './coverage/html'
}
maffelbaffel commented 7 years ago

@sshev Do these coverage checks actually work for you? I have set checks like this:

coverageReporter: {
   type: 'in-memory',
   check: {
      global: {
         statements: 50,
         branches: 50,
         functions: 50,
         lines: 80
         }
      }
   }

But my build does not fail, having branches coverage less than 50% thought. I debugged karma-coverage until https://github.com/karma-runner/karma-coverage/blob/master/lib/reporter.js#L168 and noticed, the actual value is not the value i am getting in the coverage report. I think thats the value before any remap is done, isn't it? So as it is, you cannot use the coverage checks. Would you mind looking into that again :) ?

KrekkieD commented 7 years ago

@maffelbaffel it strongly seems I have the same situation. Files without branches error saying only 50% is hit, but other reports show 0/0 branches with a 100% result.