grunt-istanbul-coverage

2018-09-14 admin

grunt-istanbul-coverage是什么

什么是grunt-istanbul-coverage,A grunt plugin to enforce coverage thresholds from istanbul coverage objects.

grunt-istanbul-coverage使用教程帮助文档

grunt-istanbul-coverage Build Status

Grunt plugin to enforce coverage thresholds from istanbul coverage JSON files

I wanted more than just insight into code coverage but a way to enforce threshold limits as well.

The “coverage” task

Overview

In your project’s Gruntfile, add a section named coverage to the data object passed into grunt.initConfig(). Thresholds, when specified as a positive number are taken to be the minimum percentage required. When a threshold is specified as a negative number it represents the maximum number of uncovered entities allowed. For example, 'statements': 90 means the minimum statement coverage is 90%. While 'statements': -10 implies that no more than 10 uncovered statements are allowed,

grunt.initConfig({
  coverage: {
    default: {
      options: {
        thresholds: {
          'statements': 90,
          'branches': 90,
          'lines': 90,
          'functions': 90
        },
        dir: 'coverage',
        root: 'test'
      }
    }
  }
})

TIP: I suggest you clean the coverage folder each time to speed up the checks and so you’re only validating the most recent coverage levels.

Using with AngularJS

This snippet from a karma.config.js will output the report and JSON files into a coverage folder.

coverageReporter: {
  type: 'json',
  dir: 'test/coverage'
};

Setup

This plugin requires Grunt >=0.4.0

If you haven’t used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you’re familiar with that process, you may install this plugin with this command:

npm install grunt-istanbul-coverage --save-dev

When the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-istanbul-coverage');

License

Copyright © 2013 Daniel Lamb Licensed under the MIT license.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-40237.html

文章标题:grunt-istanbul-coverage

回到顶部