ember-cli-code-coverage icon indicating copy to clipboard operation
ember-cli-code-coverage copied to clipboard

Add test-code-coverage command

Open mydea opened this issue 7 years ago • 8 comments

This PR adds a command ember test-code-coverage. This can be used e.g. in CI environments.

The command can also be used to simply print out the total coverage percentages, e.g. so you don't need to go looking into HTML files for them.

It takes the following parameters:

  • target-lines: The target percentage for lines covered
  • target-functions: The target percentage for functions covered
  • target-statements: The target percentage for statements covered
  • target-branches: The target percentage for branches covered

For example: ember test-code-coverage -target-lines=80 -target-branches=85

You can also configure those in the config/coverage.js file, in their camel cased form, like this:

 module.exports = {
    targetLines: 80,
    targetFunctions: 85.5,
  
    // Other configuration
    coverageEnvVar: 'COV'
  }

These values will then be the defaults when running ember test-code-coverage.

Running the command will output something like this to your console:

+ Lines covered:       60.00%   69.17%
+ Functions covered:   --.--%   72.18%
+ Statements covered:  --.--%   68.93%
- Branches covered:    70.00%   60.16%
- Test coverage check failed

For any type of check where no target is specified, it will simply output the actual value without doing any comparison.

mydea avatar Feb 26 '18 09:02 mydea

Something like this would be very nice, gitlab can parse tests output and make a good use of coverage data out of the box, but it must be provided by the tests command.

lstrzebinczyk avatar Apr 13 '18 13:04 lstrzebinczyk

@kategengler @adamjmcgrath what do you guys think about this feature?

RobbieTheWagner avatar Apr 24 '18 01:04 RobbieTheWagner

@kategengler aside from the need for a rebase, are you in favor of this feature in general?

RobbieTheWagner avatar Apr 24 '18 02:04 RobbieTheWagner

I am uncertain whether this is something we should be doing ourselves, or deferring to nyc

kategengler avatar Apr 24 '18 02:04 kategengler

If you decide to go forward with this, I'll gladly make the changes as requested. :)

mydea avatar Apr 24 '18 07:04 mydea

@kategengler I also think we may want to defer this to nyc. @adamjmcgrath what do you think?

RobbieTheWagner avatar Apr 24 '18 13:04 RobbieTheWagner

My preference would be nyc support and improving that tool, but I can't offer any help with that at the moment, so don't mind if you want to proceed with this solution.

adamjmcgrath avatar Apr 24 '18 17:04 adamjmcgrath

I agree. I think we should perhaps close, in favor of nyc.

RobbieTheWagner avatar Apr 25 '18 00:04 RobbieTheWagner