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

karma-istanbuljs-reporter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-istanbuljs-reporter

Karma reporter using Istanbul code coverage library

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

karma-istanbuljs-reporter

npm version npm downloads Build Status Windows Tests bitHound Overall Score Donate

a Karma plugin for generate code coverage using new, v1, Istanbul API

This reporter try to mimic behaviours and settings of nyc tool more than karma-coverage

Instrumentation

Use babel-istanbul-plugin for source instrumentation. Don´t forget exclude test files from instrumentation using exclude/include rules

Installation

npm

npm install karma-istanbuljs-reporter --save-dev

Usage

Add karma.conf.js file to project.

Examples of karma.conf.js

Basic

module.exports = function(config) {
  config.set({
  ...
    reporters: ['progress', 'istanbul'],
    istanbulReporter: {
      reporters: [
        { type: 'text' }
      ]
    },
  ...
  });
}

Multiple reporters

module.exports = function(config) {
  config.set({
  ...
    reporters: ['progress', 'istanbul'],
    istanbulReporter: {
      dir: 'cover/',     // changed default output dir from 'coverage/'
      reporters: [
        // reporters not supporting the `file` property
        { type: 'html', subdir: 'report-html' },
        { type: 'lcov', subdir: 'report-lcov' },
        // reporters supporting the `file` property, use `subdir` to directly
        // output them in the `dir` directory
        { type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
        { type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
        { type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
        { type: 'text', subdir: '.', file: 'text.txt' },
        { type: 'text-summary', subdir: '.', file: 'text-summary.txt' }
      ]
    },
  ...
  });
}
Supported reporters istanbul-reports

Checking coverage

karma-istanbuljs-reporter can fail tests if coverage falls below a threshold.

module.exports = function(config) {
  config.set({
  ...
    reporters: ['progress', 'istanbul'],
    istanbulReporter: {
      checkCoverage: true
    },
  ...
  });
}
Default thresholds
{
  lines: 90,
  functions: 0,
  statements: 0,
  branches: 0
}

Checking coverage with custom thresholds

module.exports = function(config) {
  config.set({
  ...
    reporters: ['progress', 'istanbul'],
    istanbulReporter: {
      checkCoverage: {
        lines: 95,
        functions: 95,
        statements: 95,
        branches: 95
      }
    },
  ...

WIP: 'Include all sources' feature

issues#1

Example

Contributing

  • Documentation improvement
  • Feel free to send any PR

License

ISC

Keywords

FAQs

Package last updated on 28 Sep 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