npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

diff-coverage

v0.1.6

Published

Git差分に対するJestテストカバレッジを計測するCLIツール

Readme

diff-coverage

A CLI tool that measures Jest/Vitest test coverage only for files changed in a git diff.

Instead of measuring whole-project coverage, diff-coverage focuses on the lines you actually changed — giving you actionable, targeted feedback.

Features

  • Measures coverage only for changed files (not the entire codebase)
  • Supports both Jest and Vitest (auto-detected)
  • Per-file coverage breakdown with uncovered line numbers
  • Configurable pass/fail threshold (exits with code 1 on failure)
  • JSON output for programmatic use
  • GitHub PR review comments with coverage gaps (review command)

Installation

npm install -g diff-coverage

Or run without installing via npx:

npx diff-coverage measure --cwd /path/to/your/project

CLI Usage

Basic — compare against main

diff-coverage measure --cwd /path/to/your/project

All options

diff-coverage measure \
  --cwd /path/to/project \              # project root (default: cwd)
  --base main \                          # base branch to diff against (default: merge-base of HEAD and main)
  --runner jest \                        # test runner: jest | vitest | auto (default: auto)
  --cmd "npx jest" \                     # override test runner command
  --ext "ts,tsx" \                       # file extensions to include (default: ts,tsx,js,jsx)
  --threshold 80 \                       # fail if line coverage is below this % (exit code 1)
  --exclude "*.mocks.ts,src/fixtures/**" # glob patterns to exclude
  --json                                 # output results as JSON
  --diff-only                            # show changed files only, skip running tests

List changed files without running tests

diff-coverage measure --diff-only --cwd /path/to/project

Example output

=== Diff Coverage Report ===

Files changed: 3
Lines:      72.5% (58/80)
Statements: 70.0% (56/80)
Functions:  66.7% (4/6)
Branches:   50.0% (6/12)

Threshold: 80% → ❌ FAIL

--- Per File ---
✅ src/services/bookService.ts
   Lines: 90%  Stmts: 88%  Fns: 100%  Branches: 75%
⚠️ src/resolvers/bookResolver.ts
   Lines: 60%  Stmts: 58%  Fns: 50%  Branches: 40%
   Uncovered lines: 45, 67, 89, 102
❌ src/utils/parser.ts
   Lines: 30%  Stmts: 28%  Fns: 0%  Branches: 0%
   Uncovered lines: 12, 15, 18, 23, 34 ... (+8)

CI Usage

# .github/workflows/coverage.yml
- name: Check diff coverage
  run: |
    npx diff-coverage measure \
      --cwd . \
      --base ${{ github.base_ref }} \
      --threshold 80

Jest / Vitest Configuration

diff-coverage works with your existing config with no changes required. For Jest, make sure coverageDirectory points to coverage/ (the default):

// jest.config.js
module.exports = {
  coverageDirectory: "coverage", // default — usually no change needed
}

Contributing

git clone https://github.com/ksugawara61/diff-coverage
cd diff-coverage
pnpm install
pnpm build
pnpm test

License

MIT