Skip to content
Latchkey

Jest "coverage threshold for ... not met" in CI

Jest compared coverage against coverageThreshold and one metric (statements, branches, functions, or lines) for the global or a path bucket was below its limit, so Jest reports the shortfall and exits non-zero.

What this error means

Jest fails after tests with "Jest: \"global\" coverage threshold for statements (80%) not met: 71.4%" (and similar lines per metric), exiting with a non-zero code.

Jest
Jest: "global" coverage threshold for statements (80%) not met: 71.4%
Jest: "global" coverage threshold for branches (70%) not met: 58.33%

Common causes

Coverage dropped below the configured threshold

New untested code lowered a metric under the value set in coverageThreshold.global or a per-path bucket.

collectCoverageFrom counts files no test imports

A wide collectCoverageFrom glob counts files no test touches at 0%, pulling the global percentage down.

How to fix it

Add tests or right-size the threshold

  1. Run with --coverage and open the report to find uncovered files and branches.
  2. Add tests for the gaps.
  3. If a metric is intentionally lower, set a realistic value in coverageThreshold.
jest.config.js
// jest.config.js
module.exports = {
  collectCoverage: true,
  coverageThreshold: {
    global: { statements: 80, branches: 70, functions: 80, lines: 80 }
  }
};

Scope collectCoverageFrom to tested source

Limit coverage collection to source you intend to test so untested glue files do not skew the global.

jest.config.js
// jest.config.js
collectCoverageFrom: ['src/**/*.{js,ts}', '!src/**/*.d.ts', '!src/**/index.ts']

How to prevent it

  • Run Jest with --coverage locally before pushing.
  • Scope collectCoverageFrom to real source.
  • Raise thresholds gradually as coverage improves.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →