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

coverage-average

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coverage-average

Compute the average coverage from istanbul text-summary.txt files, exit 1 if below threshold

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
208
increased by10.64%
Maintainers
1
Weekly downloads
 
Created
Source

coverage-average

Code Climate Build Status

Computes the average coverage from a text-summary file like:


=============================== Coverage summary ===============================
Statements   : 94.55% ( 52/55 )
Branches     : 100% ( 6/6 )
Functions    : 85% ( 17/20 )
Lines        : 94.44% ( 51/54 )
================================================================================

Why

Use it in your CI builds to force a failure if test coverage falls below your desired percentage.

Usage

Output average:

$ coverage-average path/to/text-summary.txt
Coverage average is 93.50%

Output average, exit 1 if average is below threshold

$ coverage-average path/to/text-summary.txt --limit 95
FAIL Coverage average of 93.50% is below limit of 95.00%
$ coverage-average path/to/text-summary.txt --limit 90
PASS Coverage average of 93.50% is above limit of 95.00%

Example

To have this module calculate the average coverage based on karma-coverage generated results, use a karma.conf.js file similar to:

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    files: [
      'bower_components/angular/angular.js',
      'bower_components/angular-mocks/angular-mocks.js',
      'src/**/*.js,
      'test/unit/**/*.js'
    ],
    browsers: ['PhantomJS'],
    reporters: ['dots', 'coverage'],
    preprocessors: {
      'src/**/*.js': ['coverage']
    },
    plugins: [
      'karma-phantomjs-launcher',
      'karma-coverage',
      'karma-jasmine'
    ],
    coverageReporter: {
      reporters: [{
        type: 'text-summary',
        subdir: '.',
        file: 'text-summary.txt'
      }]
    }
  });
};

The summary file will be located at coverage/text-summary/text-summary.txt.

Calculate the average with:

$ coverage-average coverage/text-summary/text-summary.txt` --limit 95

See sn-sticky-table-header for a working example.

FAQs

Package last updated on 14 Oct 2015

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