question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional fail if coverage threshold not met

See original GitHub issue

I 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:closed
  • Created 10 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
shivanykshenoycommented, Sep 5, 2015

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:

coverageReporter: {
  check: {
    global: {
       statements: 100,
       lines: 100,
       functions: 100,
       branches: 100
    }
 }
}

Thank you @Dignifiedquire! Much appreciated 😉

1reaction
vgchlcommented, Dec 24, 2013

Have a look at grunt-istanbul-coverage. It’s “A simple grunt plugin for checking aggregated coverage thresholds from istanbul coverage JSON files.”

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found