Skip to content

Test Coverage Threshold

In one line

Coverage thresholds are minimum coverage percentages configured in your test runner — if coverage drops below, the build fails.

In simple words

A coverage threshold is a rule that says 'coverage must be at least X%.' If coverage drops below that level, the test run fails — even if all tests pass.

This prevents coverage from gradually declining over time. Without thresholds, a team might add new code without tests, and coverage slowly erodes. With thresholds, any new code without tests causes the build to fail, forcing developers to maintain coverage.

You configure thresholds in Jest like this:

"jest": {
  "coverageThreshold": {
    "global": {
      "branches": 80,
      "functions": 80,
      "lines": 80,
      "statements": 80
    }
  }
}

Be careful: setting thresholds too high (like 100%) can lead to coverage-chasing — writing meaningless tests just to hit the number. Set realistic thresholds and focus on meaningful tests.

Example

json
"jest": {
  "coverageThreshold": {
    "global": {
      "branches": 80,
      "lines": 80,
      "functions": 80,
      "statements": 80
    }
  }
}

If any coverage type drops below 80%, the test run fails.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary