-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a 'checkCoverage' option to compare coverage with a defined threshold #21
Comments
+1 |
1 similar comment
👍 |
👍 and bump instanbul to 0.2.7 so I can generate clover reports :) |
👍 |
+1 |
+1 bump |
I'm not that much involved in this plugin development anymore, but feel free to PR guys. I'll review it. |
+1 |
This will accomplish what you guys are looking for. Would be nice to add this to the documentation. First number is the threshold for Red to Yellow, second number is the threshold for Yellow to Green // @File: karma.config.js
coverageReporter: {
type : 'html',
dir: 'reports',
subdir: 'coverage',
watermarks: {
statements: [50,75],
lines: [50,75],
functions: [50,75],
branches:[50,75]
}
}, |
@stramel if the thresholds are red, is there a way for the task to fail? |
@peter-mouland Good question! I would have to look into it. |
thanks for the interest, i've done it quite crudely with gulp tasks. unfortunately i dont have the time to go through the coverage plug and see how to do it properly. hopefully one day....
|
Watermarks allow a user to change the color thresholds for Red, Yellow, and Green for each of; statements, functions, branches, and lines. Solves issue karma-runner#21
The watermarks are just settings for the report output colour breakpoints it seems (which is nice to see how to control this), the request looks more like a way to send information to istanbul check-coverage
This would be very useful I use istanbul with mocha on backend node.js projects with check-coverage there is almost essential. Much like how the OP has stated for configuration. At the moment it appears looking at the code only the report option is being implemented, so implementation of check-coverage would be great 👍 |
@andrew-cunliffe @peter-mouland I think just installing $ npm install istanbul // File: Gulpfile.js
// NOTE: This is an untested snippet of code
var spawn = require('child_process').spawn;
gulp.task('coverage:check', function () {
var child = spawn('istanbul', [
'--statements=100',
'--functions=100',
'--branches=100',
'--lines=100'
], {cwd: process.cwd()});
child.on('close', function (errorCode) {
// Handle Error
}); |
I'm working on a PR for this issue. The implementation mostly comes from https://github.com/gotwarlost/istanbul/blob/master/lib/command/check-coverage.js and is based on the istanbul configuration file. It will cause the build to fail by modifying the Info from the README: checkType: Object Description: This will be used to configure minimum threshold enforcement for coverage results. If the thresholds are not met, karma will return failure. Thresholds, when specified as a positive number are taken to be the minimum percentage required. When a threshold is specified as a negative number it represents the maximum number of uncovered entities allowed. For example,
coverageReporter: {
check: {
global: {
statements: 50,
branches: 50,
functions: 50,
lines: 50,
excludes: [
'foo/bar/**/*.js'
]
},
each: {
statements: 50,
branches: 50,
functions: 50,
lines: 50,
excludes: [
'other/directory/**/*.js'
],
overrides: {
'baz/component/**/*.js': {
statements: 98
}
}
}
}
} |
Add check option to coverageReporter options. Supports similar options to istanbul's check-coverage feature. It will cause karma to return a non-zero exit code if coverage thresholds are not met. Closes karma-runner#21
Add check option to coverageReporter options. Supports similar options to istanbul's check-coverage feature. It will cause karma to return a non-zero exit code if coverage thresholds are not met. Closes karma-runner#21
Add check option to coverageReporter options. Supports similar options to istanbul's check-coverage feature. It will cause karma to return a non-zero exit code if coverage thresholds are not met. Closes karma-runner#21
ping :) can someone look at PR #141 please? |
Add check option to coverageReporter options. Supports similar options to istanbul's check-coverage feature. It will cause karma to return a non-zero exit code if coverage thresholds are not met. Closes karma-runner#21
Add check option to coverageReporter options. Supports similar options to istanbul's check-coverage feature. It will cause karma to return a non-zero exit code if coverage thresholds are not met. Closes karma-runner#21
At the moment it's not possible to run the 'check-coverage' command available in Istanbul. It would be cool to have a way of specifying thresholds for statement coverage, function coverage and branch coverage.
I was thinking something like
to be added to the Karma conf file.
Thoughts?
The text was updated successfully, but these errors were encountered: