coveralls
takes json-cov output into stdin and POSTs to coveralls.io
Last updated 11 years ago by cainus .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ npm install coveralls 
SYNC missed versions from official npm registry.

node-coveralls

Build Status Coverage Status

Coveralls.io support for Node.js. Get the great coverage reporting of coveralls.io and add a cool coverage button (like the one above) to your README.

Supported CI services:

Installation:

Add the latest version of coveralls to your package.json:

npm install coveralls --save-dev

If you're using mocha, add mocha-lcov-reporter to your package.json:

npm install mocha-lcov-reporter --save-dev

Usage:

This script bin/coveralls.js can take standard input from any tool that emits the lcov data format (including mocha's LCOV reporter) and send it to coveralls.io to report your code coverage there.

Once your app is instrumented for coverage, and building, you need to pipe the lcov output to ./node_modules/coveralls/bin/coveralls.js.

This library currently supports Travis CI with no extra effort beyond piping the lcov output to coveralls. However, if you're using a different build system, there are a few necessary environment variables:

  • COVERALLS_SERVICE_NAME (the name of your build system)
  • COVERALLS_REPO_TOKEN (the secret repo token from coveralls.io)
  • COVERALLS_GIT_BRANCH (the branch name)

There are optional environment variables for other build systems as well:

  • COVERALLS_FLAG_NAME (a flag name to differentiate jobs, e.g. Unit, Functional, Integration)
  • COVERALLS_SERVICE_NUMBER (a number that uniquely identifies the build)
  • COVERALLS_SERVICE_JOB_ID (an ID that uniquely identifies the build's job)
  • COVERALLS_SERVICE_JOB_NUMBER (a number that uniquely identifies the build's job)
  • COVERALLS_RUN_AT (a date string for the time that the job ran. RFC 3339 dates work. This defaults to your build system's date/time if you don't set it)
  • COVERALLS_PARALLEL (set to true when running jobs in parallel, requires a completion webhook. More info here: https://docs.coveralls.io/parallel-build-webhook)

GitHub Actions CI

If you are using GitHub Actions CI, you should look into coverallsapp/github-action.

Parallel runs example workflow.yml

CircleCI Orb

Here's our Orb for quick integration: coveralls/coveralls

Workflow example: config.yml

Travis-CI

Parallel jobs example: .travis.yml

Jest

  • Install jest

  • Use the following to run tests and push files to coveralls on success:

    jest --coverage && coveralls < coverage/lcov.info
    

Check out an example here which makes use of Travis CI build stages

Mocha + Blanket.js

  • Install blanket.js

  • Configure blanket according to docs.

  • Run your tests with a command like this:

    NODE_ENV=test YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha \
      --require blanket \
      --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
    

Mocha + JSCoverage

Instrumenting your app for coverage is probably harder than it needs to be (read here), but that's also a necessary step.

In mocha, if you've got your code instrumented for coverage, the command for a Travis CI build would look something like this:

YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha test -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js

Check out an example Makefile from one of my projects for an example, especially the test-coveralls build target. Note: Travis CI runs npm test, so whatever target you create in your Makefile must be the target that npm test runs (This is set in package.json's scripts property).

Istanbul

With Mocha:

istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

With Jasmine:

istanbul cover jasmine-node --captureExceptions spec/ && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

Nodeunit + JSCoverage

Depend on nodeunit, jscoverage, and coveralls:

npm install nodeunit jscoverage coveralls --save-dev

Add a coveralls script to "scripts" in your package.json:

"scripts": {
  "test": "nodeunit test",
  "coveralls": "jscoverage lib && YOURPACKAGE_COVERAGE=1 nodeunit --reporter=lcov test | coveralls"
}

Ensure your app requires instrumented code when process.env.YOURPACKAGE_COVERAGE variable is defined.

Run your tests with a command like this:

npm run coveralls

For detailed instructions on requiring instrumented code, running on Travis CI and submitting to coveralls see this guide.

Poncho

Client-side JS code coverage using PhantomJS, Mocha and Blanket:

  • Configure Mocha for browser

  • Mark target script(s) with data-cover HTML attribute

  • Run your tests with a command like this:

    ./node_modules/.bin/poncho -R lcov test/test.html | ./node_modules/coveralls/bin/coveralls.js
    

Lab

lab -r lcov | ./node_modules/.bin/coveralls

nyc

Works with almost any testing framework. Simply execute npm test with the nyc bin followed by running its reporter:

nyc npm test && nyc report --reporter=text-lcov | coveralls

TAP

Simply run your tap tests with the COVERALLS_REPO_TOKEN environment variable set and tap will automatically use nyc to report coverage to coveralls.

Command Line Parameters

Usage: coveralls.js [-v] filepath

Optional arguments:

  • -v, --verbose
  • filepath - optionally defines the base filepath of your source files.

Running locally

If you're running locally, you must have a .coveralls.yml file, as documented in their documentation, with your repo_token in it; or, you must provide a COVERALLS_REPO_TOKEN environment variable on the command-line.

If you want to send commit data to coveralls, you can set the COVERALLS_GIT_COMMIT environment-variable to the commit hash you wish to reference. If you don't want to use a hash, you can set it to HEAD to supply coveralls with the latest commit data. This requires git to be installed and executable on the current PATH.

Contributing

I generally don't accept pull requests that are untested or break the build, because I'd like to keep the quality high (this is a coverage tool after all!).

I also don't care for "soft-versioning" or "optimistic versioning" (dependencies that have ^, x, > in them, or anything other than numbers and dots). There have been too many problems with bad semantic versioning in dependencies, and I'd rather have a solid library than a bleeding-edge one.

Current Tags

  • 3.1.1                                ...           latest (3 years ago)

71 Versions

  • 3.1.1                                ...           3 years ago
  • 3.1.0                                ...           5 years ago
  • 3.0.14                                ...           5 years ago
  • 3.0.13                                ...           5 years ago
  • 3.0.12                                ...           5 years ago
  • 3.0.11                                ...           5 years ago
  • 3.0.10                                ...           5 years ago
  • 3.0.9                                ...           5 years ago
  • 3.0.8                                ...           5 years ago
  • 3.0.7                                ...           5 years ago
  • 3.0.6                                ...           5 years ago
  • 3.0.5                                ...           5 years ago
  • 3.0.4                                ...           5 years ago
  • 3.0.3                                ...           6 years ago
  • 3.0.2                                ...           6 years ago
  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.13.3                                ...           7 years ago
  • 2.13.2                                ...           7 years ago
  • 2.13.1                                ...           8 years ago
  • 2.13.0                                ...           8 years ago
  • 2.12.0                                ...           8 years ago
  • 2.11.16                                ...           8 years ago
  • 2.11.15                                ...           8 years ago
  • 2.11.14                                ...           8 years ago
  • 2.11.13                                ...           8 years ago
  • 2.11.12                                ...           8 years ago
  • 2.11.11                                ...           8 years ago
  • 2.11.10                                ...           8 years ago
  • 2.11.9                                ...           9 years ago
  • 2.11.8                                ...           9 years ago
  • 2.11.7                                ...           9 years ago
  • 2.11.6                                ...           9 years ago
  • 2.11.5                                ...           9 years ago
  • 2.11.4                                ...           9 years ago
  • 2.11.3                                ...           9 years ago
  • 2.11.2                                ...           10 years ago
  • 2.11.1                                ...           10 years ago
  • 2.11.0                                ...           10 years ago
  • 2.10.1                                ...           10 years ago
  • 2.10.0                                ...           11 years ago
  • 2.8.0                                ...           11 years ago
  • 2.7.1                                ...           11 years ago
  • 2.7.0                                ...           11 years ago
  • 2.6.1                                ...           11 years ago
  • 2.6.0                                ...           11 years ago
  • 2.5.0                                ...           11 years ago
  • 2.3.0                                ...           11 years ago
  • 2.2.0                                ...           11 years ago
  • 2.1.0                                ...           11 years ago
  • 2.0.16                                ...           11 years ago
  • 2.0.15                                ...           11 years ago
  • 2.0.13                                ...           11 years ago
  • 2.0.12                                ...           11 years ago
  • 2.0.11                                ...           11 years ago
  • 2.0.10                                ...           11 years ago
  • 2.0.9                                ...           11 years ago
  • 2.0.8                                ...           11 years ago
  • 2.0.7                                ...           12 years ago
  • 2.0.6                                ...           12 years ago
  • 2.0.5                                ...           12 years ago
  • 2.0.4                                ...           12 years ago
  • 2.0.3                                ...           12 years ago
  • 2.0.2                                ...           12 years ago
  • 2.0.1                                ...           12 years ago
  • 2.0.0                                ...           12 years ago
  • 1.1.3                                ...           12 years ago
  • 1.1.2                                ...           12 years ago
  • 1.1.1                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 31
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (6)

© 2010 - cnpmjs.org x YWFE | Home | YWFE