coverage-putty

raw JSON →
0.1.0 verified Fri May 01 auth: no javascript

coverage-putty is a transform preprocessor for Jest that uses Istanbul to exclude JavaScript helper functions generated by the TypeScript transpiler from coverage reports. Version 0.1.0 is the current release, with no recent updates. It helps avoid skewing coverage metrics with boilerplate TypeScript output. Only works with Jest and Istanbul; requires manual transform configuration. No competing packages address this exact niche.

error Cannot find module 'coverage-putty'
cause Package not installed or not listed in devDependencies.
fix
Run npm install coverage-putty --save-dev
error TypeError: Cannot read property 'transform' of undefined
cause Jest configuration is missing or malformed.
fix
Ensure 'jest' key exists in package.json with 'transform' object containing the pattern.
gotcha Transform file pattern must be a JavaScript RegExp string, not a file glob.
fix Ensure the pattern starts with 'src/' and includes proper escaping for dots: 'src/.*\\.js$'.
gotcha coverage-putty only works with JavaScript files that are output of TypeScript compilation; will not work if you point it at .ts files.
fix Compile TypeScript to JS first (e.g., via ts-jest or tsc), then apply the transform on the JS files.
deprecated The package has not been updated since 2018; may not be compatible with latest Jest versions.
fix Consider using 'jest-coverage-ignore' or similar alternatives, or test with your Jest version.
npm install coverage-putty
yarn add coverage-putty
pnpm add coverage-putty

Configures Jest to use coverage-putty for transforming JS files, excluding TypeScript-generated helpers from coverage.

// package.json
{
  "jest": {
    "collectCoverage": true,
    "coverageDirectory": "report/",
    "collectCoverageFrom": [ "src/**/*.js" ],
    "transform": {
      "src/.*\\.js$": "coverage-putty/istanbul-ignore.js"
    }
  }
}

// Run tests
npx jest --coverage