New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esnext-coverage

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esnext-coverage

Modular coverage tools for the modern web

  • 0.0.9
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

esnext-coverage

NPM version

Modular coverage tools for the modern web.

Installation

npm install --save-dev esnext-coverage

Usage with test frameworks

See esnext-coverage-examples repository for more details.

Tape

Require esnext-coverage when running Tape:

tape -r esnext-coverage test/*.js

Mocha

Require esnext-coverage when running Mocha:

mocha -r esnext-coverage test/*.js

Jasmine

Replace babel-register with esnext-coverage in the list of Jasmine helpers:

"helpers": [
  "../node_modules/esnext-coverage/lib/esnext-coverage.js"
]

Options

The esnext-coverage configuration is an object that extends Babel API options with two additional properties:

reporters

A reporter signature is an object containing formatter (String or Function, defaults to JSON.stringify), console (Boolean, defaults to false) and outFile (String, optional) properties.

When formatter is a String, esnext-coverage will attempt to require(`esnext-coverage-format-${formatter}`) similar to Babel requiring plugins.

reporters: [
  // Format using esnext-coverage-format-text,
  // and write the formatted output to stdout:
  {formatter: 'text', console: true},
  // Format using esnext-coverage-format-html,
  // and write the formatted output to a file:
  {formatter: 'html', outFile: 'reports/coverage/coverage.html'},
  // Format using a custom formatter function,
  // and write the formatted output to a file:
  {formatter: myFormatter, outFile: 'reports/coverage/coverage.my'}
]

If reporters are not specified, a default reporter is used with 'json' as formatter and 'reports/coverage/coverage.json' file as output:

reporters: [
  {formatter: 'json', outFile: 'reports/coverage/coverage.json'}
]

thresholds

Both global and local properties are optional. No threshold is enforced by default.

thresholds: {
  global: {
    statement: 100,
    branch: 100,
    function: 100,
    line: 100
  },
  local: {
    statement: 100,
    branch: 100,
    function: 100,
    line: 100
  }
}

Configuration

Add an "esnext-coverage": {...options} entry in your package.json file or create either .esnextcoverage.js or .esnextcoveragerc file in the root of your project.

package.json

{
  "name": "my project",
  "version": "1.2.3",
  "esnext-coverage": {
    "only": "test/*.js",
    "reporters": [
      {"formatter": "text", "console": true}
    ]
  }
}

.esnextcoverage.js

module.exports = {
  only: 'test/*.js',
  reporters: [
    {formatter: 'text', console: true}
  ]
};

.esnextcoveragerc

{
  "only": "test/*.js",
  "reporters": [
    {"formatter": "text", "console": true}
  ]
}

CLI usage

Usage: esnext-coverage [options] [command]

Commands:

  instrument [options] [file]  instruments code
  collect [options] [file]     collects coverage data
  format [options] [file]      formats coverage data

Options:

  -h, --help     output usage information
  -V, --version  output the version number

instrument

Reads code from stdin or from a file, instruments it, and writes the instrumented code to stdout or to a file.

collect

Reads code from stdin or from a file, collects coverage data, and writes the result to stdout or to a file.

format

Transforms coverage data to the specified format.

Prior art

esnext-coverage has been inspired by Adana.

License

MIT License

FAQs

Package last updated on 17 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc