Coverage Configuration in Jest

From the Jest cheat sheet · Code Coverage · verified Jul 2026

Coverage Configuration

Setting up and interpreting code coverage reports

javascript
// jest.config.js
module.exports = {
  collectCoverage: true,
  collectCoverageFrom: [
    'src/**/*.{js,jsx,ts,tsx}',
    '!src/index.js',
    '!src/**/*.test.{js,jsx,ts,tsx}',
    '!src/**/*.stories.{js,jsx,ts,tsx}'
  ],
  coverageThreshold: {
    global: {
      branches: 80,
      functions: 80,
      lines: 80,
      statements: 80
    }
  },
  coverageReporters: ['text', 'lcov', 'html']
}

// Run with coverage
npm test -- --coverage
npm test -- --coverage --watchAll=false
💡 HTML coverage reports show line-by-line coverage visually
⚡ Set different thresholds for critical vs non-critical code
📌 Use istanbul ignore comments sparingly for untestable code
🟢 Coverage helps identify untested code, not test quality
coverageconfiguration
Back to the full Jest cheat sheet