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.
Common errors
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.
Warnings
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.
Install
npm install coverage-putty yarn add coverage-putty pnpm add coverage-putty Imports
- istanbul-ignore.js wrong
transform: { 'src/.*\\.js$': 'coverage-putty' }correcttransform: { 'src/.*\\.js$': 'coverage-putty/istanbul-ignore.js' } - Coordination wrong
npm install coverage-putty --savecorrectnpm install coverage-putty --save-dev - Configuration wrong
Use transformIgnorePatternscorrectUse Jest's transform option in package.json or jest.config.js
Quickstart
// package.json
{
"jest": {
"collectCoverage": true,
"coverageDirectory": "report/",
"collectCoverageFrom": [ "src/**/*.js" ],
"transform": {
"src/.*\\.js$": "coverage-putty/istanbul-ignore.js"
}
}
}
// Run tests
npx jest --coverage