Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-istanbul-threshold

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-istanbul-threshold

Karma reporter that checks coverage thresholds with coverage data generated by karma-coverage. Because it reads its data from a json file, it can also handle remapped coverage data provided by karma-remap-istanbul to allow source-map support.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
500
decreased by-11.82%
Maintainers
1
Weekly downloads
 
Created
Source

karma-istanbul-threshold

Checks coverage thresholds by using json coverage files generated by Istanbul, karma-coverage or karma-remap-istanbul.

While karma-coverage already allows threshold checks, it unfortunately does not play well with source maps.

karma-remap-istanbul can convert results generated by karma-coverage but does not offer threshold checking.

This plugin fills that gap by using a json file for threshold checking that can be generated by Istanbul or karma-coverage (which internally uses Istanbul). Those json files can be remapped by karma-remap-istanbul to enable source-map support for threshold checking.

Installation

The easiest way is to install karma-istanbul-threshold as a devDependency, by running

npm install karma-istanbul-threshold --save-dev

Configuration

Add the plugin, reporter and reporter configuration in your karma.conf.js.

{
  plugins: ['karma-istanbul-threshold'],
  reporters: ['progress', 'karma-istanbul-threshold'],
  istanbulThresholdReporter: {
    src: 'path/to/coverage-report.json',
    basePath: path.resolve(__dirname, 'path/to/source'),
    thresholds: {
      global: {
        statements: 90,
        branches: 90,
        lines: 70,
        functions: 90,
      },
      each: {
        statements: 80,
        branches: 80,
        lines: 60,
        functions: 80,
      },
    },    
  }
}

Example configuration with karma-coverage and karma-remap-istanbul

{
  preprocessors: {
    'build/**/!(*spec).js': ['coverage']
  },
  plugins: ['karma-remap-istanbul', 'karma-coverage', 'karma-istanbul-threshold'],
  reporters: ['progress', 'coverage', 'karma-remap-istanbul', 'istanbul-threshold'],
  coverageReporter: {
    reporters: [
      { type: 'json', dir: 'tmp/coverage', subdir: '.', file: 'coverage-unmapped.json' }
    ],
  },  
  remapIstanbulReporter: {
    src: 'tmp/coverage/coverage-unmapped.json',
    reports: {
      'json': 'tmp/coverage/coverage-mapped.json'
    },
  },
  istanbulThresholdReporter: {
    src: 'tmp/coverage/coverage-mapped.json',
    basePath: path.resolve(__dirname, 'path/to/source'),
    thresholds: {
      global: {
        statements: 90,
        branches: 90,
        lines: 70,
        functions: 90,
      },
      each: {
        statements: 80,
        branches: 80,
        lines: 60,
        functions: 80,
      },
    },    
  }
}

Keywords

FAQs

Package last updated on 11 Aug 2016

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