Skip to content
Latchkey

Istanbul/nyc "Coverage for lines does not meet threshold" in CI

nyc ran check-coverage and one metric (lines, statements, branches, or functions) was below the configured global or per-file threshold, so nyc prints the gap and exits non-zero, failing the job.

What this error means

nyc fails with "ERROR: Coverage for lines (74.2%) does not meet global threshold (80%)" and the test command exits with a non-zero code.

nyc
ERROR: Coverage for lines (74.2%) does not meet global threshold (80%)
ERROR: Coverage for branches (61.5%) does not meet global threshold (70%)

Common causes

Coverage dropped below a configured threshold

New untested code lowered a metric under the lines/branches/functions/statements limit set in nyc config.

Files were instrumented but not exercised

A broad include pulls in files no test touches, dragging the global percentage below the threshold.

How to fix it

Add tests or scope the thresholds

  1. Open the HTML report (coverage/index.html) to find uncovered lines/branches.
  2. Add tests for the gaps the report highlights.
  3. If a metric is intentionally lower for now, set a realistic threshold in config.
.nycrc.json
// .nycrc.json
{
  "check-coverage": true,
  "lines": 80,
  "branches": 70,
  "functions": 80,
  "statements": 80
}

Exclude files that should not count

Remove config, generated, or test-helper files from instrumentation so the percentage reflects real source.

.nycrc.json
// .nycrc.json
{ "exclude": ["**/*.config.js", "**/generated/**", "test/**"] }

How to prevent it

  • Run nyc check-coverage locally before pushing.
  • Scope include/exclude so only real source is measured.
  • Raise thresholds gradually as coverage grows.

Frequently asked questions

What causes ""Coverage for lines does not meet threshold""?
New untested code lowered a metric under the lines/branches/functions/statements limit set in nyc config.
How do I fix "Coverage for lines does not meet threshold"?
Add tests or scope the thresholds

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card