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.
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
- Open the HTML report (
coverage/index.html) to find uncovered lines/branches. - Add tests for the gaps the report highlights.
- If a metric is intentionally lower for now, set a realistic threshold in config.
// .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
{ "exclude": ["**/*.config.js", "**/generated/**", "test/**"] }How to prevent it
- Run
nyc check-coveragelocally before pushing. - Scope
include/excludeso only real source is measured. - Raise thresholds gradually as coverage grows.