Optional fail if coverage threshold not met
See original GitHub issueI have recently started using Karma, and the team keeps adding code which drops the coverage below a level I am happy with, it would be great if Karma could fail the tests on CI based on a config setting like a percentage threshold e.g.
coverageReporter = {
threshold: 80
}
I might have a look at doing this too if I can however it might be relating to the plugin used for coverage?
Wanted to add this here as a possible new feature as I cant see any alternatives to when I get to putting my code in and finding others have not been adding tests for their code 😃
Issue Analytics
- State:
- Created 10 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Jest test coverage does not fail when threshold is not met
My understanding from the Jest documentation is that an error should be returned when coverage thresholds are not met.
Read more >Configuring code coverage in Jest, the right way
In this brief tutorial we see how to configure code coverage for Jest, ... test fails if we do not meet the desired...
Read more >Fail a phpunit test if coverage goes below a threshold - cylab.be
So here is a trick to fail your pipeline if the coverage of your phpunit tests goes below a threshold. The trick consists...
Read more >Configuring Jest
Thresholds can be specified as global , as a glob, and as a directory or file path. If thresholds aren't met, jest will...
Read more >Code Coverage: The Metric That Makes Your Tests Worse.
Let's have a look at the second situation where the actual coverage is below that arbitrary threshold even though you have written all...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue is closed because it has been addressed in karma-coverage as per the following commit: https://github.com/karma-runner/karma-coverage/commit/bc63b1583ec95abbf4c74df5f8346e0c8f048220
basically you add a check like below for the coverageReporter, in the karma.config file:
Thank you @Dignifiedquire! Much appreciated 😉
Have a look at grunt-istanbul-coverage. It’s “A simple grunt plugin for checking aggregated coverage thresholds from istanbul coverage JSON files.”