jest-filter
v1.0.0
Published
A CLI tool to display Jest coverage as a formatted table
Readme
jest-filter
A powerful CLI tool to display Jest coverage as a formatted, color-coded table. Instantly see which files and lines need more coverage, with advanced filtering, sorting, and detailed reporting.
Features & Unique Selling Points
- Advanced Coverage Filtering:
- Filter files by coverage percentage for statements, branches, functions, or lines.
- Set lower/upper thresholds and filter by specific coverage type.
- Customizable Sorting:
- Sort files by any coverage metric, ascending or descending.
- Option to sort globally (
--flat-sort) or within folder hierarchy.
- Professional, Readable Output:
- Uses
cli-table3for clean, aligned tables. - Dynamic column widths to prevent data trimming.
- Color-coded coverage values and uncovered lines (red/yellow) for instant visual feedback.
- Uses
- Detailed Uncovered Lines Reporting:
- Shows uncovered statement and branch lines, color-coded, for each file.
- Easy Integration:
- Works with any Jest project.
- CLI interface with intuitive options.
- Demo & Example Project:
- Includes an
example/folder for quick testing and demonstration.
- Includes an
Installation
npm install -g jest-filterUsage
jest-filter [options]Options
-s, --sort <field>: Sort by field (statements,branches,functions,lines). Default:statements-o, --order <order>: Sort order (asc,desc). Default:asc-l, --lower <threshold>: Filter files with coverage below this threshold. Default:0-u, --upper <threshold>: Filter files with coverage above this threshold. Default:100-t, --filter-field <field>: Coverage field to filter by (statements,branches,functions,lines). Default:statements--flat-sort: Sort all files globally, ignoring folder hierarchy.-p, --path <path>: Use existing coverage from path (skips Jest run). Defaults tocoverageif no path provided.
Output Example
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------------------------------------------------------------------------------------
stacks/apis/src/services/baseService.ts | 96.03 | 79.72 | 100.00 | 96.03 | 204,207,223,228 39,76,86-89,103,172,198,199
...etc- Red: Uncovered statement lines
- Yellow: Uncovered branch lines
- Green: High coverage
- Yellow: Medium coverage
- Red: Low coverage
Example
See the example/ folder for a demo project and sample configuration.
Development
To run the example tests:
cd example
npm install
npm testWhy Use jest-filter?
- Instantly see which files need more coverage and where.
- Quickly identify problematic lines and branches.
- Professional, readable output for CI, code reviews, and team dashboards.
- Highly customizable to fit any workflow.
License
MIT
