Home Manual Reference Source Test

Coveralls for JS

Runtime Release License Downloads Dependencies Coverage Build

Send LCOV coverage reports to the Coveralls service, in JavaScript.

Requirements

The latest Node.js and npm versions. If you plan to play with the sources, you will also need the latest Gulp.js version.

Usage

Command line interface

The easy way. From a command prompt with administrator privileges, install the coveralls executable:

$ npm install --global @cedx/coveralls

Then use it to upload your coverage reports:

$ coveralls --help

  Usage: coveralls [options]

  Send a LCOV coverage report to the Coveralls service.

  Options:

    -h, --help         output usage information
    -v, --version      output the version number
    -f, --file <file>  path to the coverage report

For example:

$ coveralls -f build/lcov.info

Programming interface

The hard way. From a command prompt, install the library:

$ npm install --save @cedx/coveralls

Now, in your JavaScript code, you can use the Client class to upload your coverage reports:

const {readFileSync} = require('fs');
const {Client} = require('@cedx/coveralls');

async function main() {
  try {
    let coverage = readFileSync('/path/to/coverage.report', 'utf8');
    await (new Client).upload(coverage);
    console.log('The report was sent successfully.');
  }

  catch (error) {
    console.log(`An error occurred: ${error}`);
  }
}

Supported coverage formats

Currently, this package only supports the de facto standard: the LCOV format.

Supported CI services

This project has been tested with Travis CI service, but these services should also work with no extra effort:

Environment variables

If your build system is not supported, you can still use this package. There are a few environment variables that are necessary for supporting your build system:

There are optional environment variables:

The full list of supported environment variables is available in the source code of the Configuration class (see the fromEnvironment() static method).

The .coveralls.yml file

This package supports the same configuration sources as the Coveralls ones:
Coveralls currently supports

See also

License

Coveralls for JS is distributed under the Apache License, version 2.0.