Skip to content
Latchkey

Jest "coverage threshold ... not met" - Fails the Build in CI

All tests passed but Jest exited non-zero because measured coverage fell below a configured coverageThreshold. New untested code, or files that were not collected, dragged a metric under the bar.

What this error means

The run prints the coverage table, then "Jest: \"global\" coverage threshold for lines (80%) not met: 76.4%" and fails the job even though every test is green.

jest
Jest: "global" coverage threshold for lines (80%) not met: 76.42%
Jest: "global" coverage threshold for branches (75%) not met: 71.1%

Common causes

New code added without tests

Recently added lines or branches are untested, pulling the percentage below the configured threshold.

Files not included in collection

Without collectCoverageFrom, only imported files are counted; entirely untested files are invisible, then suddenly counted once imported, dropping the average.

How to fix it

Add tests for the uncovered lines

Open the HTML/text report to see exactly which lines and branches are missing, and cover them.

Terminal
jest --coverage
# open coverage/lcov-report/index.html to find red lines

Set thresholds and collection explicitly

jest.config.js
// jest.config.js
module.exports = {
  collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts'],
  coverageThreshold: { global: { lines: 80, branches: 75 } },
};

How to prevent it

  • Define collectCoverageFrom so all source is measured consistently.
  • Add tests with new code so coverage never regresses below the bar.
  • Ratchet thresholds up over time rather than down.

Frequently asked questions

What causes ""coverage threshold ... not met""?
Recently added lines or branches are untested, pulling the percentage below the configured threshold.
How do I fix "coverage threshold ... not met"?
Open the HTML/text report to see exactly which lines and branches are missing, and cover them.

Related guides

References

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