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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@connectis/diff-test-coverage

v1.5.3

Published

Commandline tool which calculates test coverage of (source control) diffs.

Downloads

21,306

Readme

diff-test-coverage

A Node.js commandline tool which filters test coverage based on a (source control) diff.

NPM versionDependency Status

Supported coverage report formats:

  • lcov
  • cobertura
  • clover
  • jacoco
  • golang-cover

Supported source control systems:

  • Git
  • Mercurial
  • Anything else that produces unified diffs.

Installation

  1. Install Node.js with NPM
  2. npm i -g @connectis/diff-test-coverage

Example output

Screenshot

Usage and options

Execute diff-test-coverage to see the documentation.

Usage:
1. Execute your tests to generate your test coverage reports.
2. Figure out what Git or Mercurial command to use to generate your diff (see Examples below).
3. Execute: <diff command> | diff-test-coverage -c <coverage report glob> -t <coverage report type> --

Options:
  --help                   Show help  [boolean]
  --version                Show version number  [boolean]
  -c, --coverage           Glob pattern(s) that specify which coverage report files to use.  [array] [required]
  -t, --type               The type of coverage report. When provided multiple times the types will be mapped to the matching coverage glob patterns.  [array] [required] [choices: "lcov", "cobertura", "clover", "jacoco", "golang-cover"]
  -l, --line-coverage      Required line coverage percentage on the diff. The application will exit with -1 if this is not reached.  [number] [default: 80]
  -b, --branch-coverage    Required branch coverage percentage on the diff. The application will exit with -1 if this is not reached.  [number] [default: 80]
  -f, --function-coverage  Required function coverage percentage on the diff. The application will exit with -1 if this is not reached.  [number] [default: 80]
  --diff-base-dir          The base directory for resolving relative paths in the diff. Uses current working directory by default.  [string] [default: `process.cwd()`]
  --diff-filter            Glob pattern(s) that specify which files from the diff should be included.  [array]
  --log-base-dir           The base directory for resolving relative paths in the console logger. Uses current working directory by default.  [string] [default: `process.cwd()`]
  --log-template           The information which should be logged to the console.  [array] [choices: "diff-files", "coverage-files-line", "coverage-files-complete", "totals-line", "totals-complete", "errors"] [default: ["coverage-files-complete","totals-complete","errors"]]
  --color                  Whether colors should be used in the log. Default: autodetect by 'chalk'.  [boolean]

Examples:
  git diff master...MY-BRANCH | diff-test-coverage -c **/coverage.xml -t cobertura --                                                                     Runs 'diff-test-coverage' with a git diff and Cobertura coverage reports.
  hg export -r "branch(.) and not merge()" | diff-test-coverage -c **/target/site/jacoco/jacoco.xml -t jacoco --                                          Runs 'diff-test-coverage' with a mercurial diff and Jacoco coverage reports.
  <diff command> | diff-test-coverage --log-template diff-files coverage-files-line totals-line errors <other args> --                                    Runs 'diff-test-coverage' with custom logging.
  <diff command> | diff-test-coverage --diff-filter *.java *.kt --log-template diff-files coverage-files-complete totals-complete errors <other args> --  Runs 'diff-test-coverage' with the diff filtered on Java and Kotlin files.
  <diff command> | diff-test-coverage --no-color <other args> --                                                                                          Runs 'diff-test-coverage' without color in the log.
  git diff master...MY-BRANCH                                                                                                                             Creates a diff of the Git branch 'MY-BRANCH' which originated from the master branch.
  hg export -r "branch(.) and not merge()"                                                                                                                Creates a diff of the current Mercurial branch, excluding any merge commits.
  hg export -r "branch(MY-BRANCH) and not merge()"                                                                                                        Creates a diff of the Mercurial branch MY-BRANCH, excluding any merge commits.