grunt-simple-nyc

3.0.1 • Public • Published

Build Status downloads npm Maintainability Test Coverage dependencies

grunt-simple-nyc

A grunt wrapper for nyc

Getting Started

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-simple-nyc --save-dev

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

grunt.loadNpmTasks('grunt-simple-nyc');

Alternatively, install task-master and let it manage this for you.

The "nyc" task

Overview

In your project's Gruntfile, add a section named nyc to the data object passed into grunt.initConfig(). This task is a simple-cli task, so it can be configured in accordance with the examples there. A simple example is:

grunt.initConfig({
  nyc: {
    cover: {
      options: {
        cwd: 'server',
        include: ['lib/**', 'routes/**'],
        exclude: '*.test.*',
        reporter: ['lcov', 'text-summary'],
        reportDir: 'server/coverage'
        all: true
      },
      cmd: false,
      args: ['grunt', 'mocha:unit']
    },
    report: {
      options: {
        reporter: 'text-summary'
      }
    }
  }
});
 
// grunt nyc:cover will run
// nyc --cwd server --include lib/** --include routes/** --exclude *.test.*
//   --reporter--reporter--reporter--reporter lcov --reporter text-summary
//   --report-dir server/coverage --all grunt mocha:unit
//
// whereas grunt nyc:report will run
// nyc report --reporter text-summary

If you need to pass arguments to the process that runs your tests (grunt mocha:unit in the example above), you need to add them to args after the command name (alternatively, you can add them in rawArgs). E.g.

grunt.initConfig({
  cover: {
    cmd: false,
    args: ['grunt', 'mocha:unit', '--require', 'should']
  }
});
 
// or
 
grunt.initConfig({
  cover: {
    cmd: false,
    args: ['grunt', 'mocha:unit'],
    rawArgs: ['--require', 'should']
  }
});

Contributing

Please see the contribution guidelines.

/grunt-simple-nyc/

    Package Sidebar

    Install

    npm i grunt-simple-nyc

    Weekly Downloads

    5,734

    Version

    3.0.1

    License

    MIT

    Unpacked Size

    15.5 kB

    Total Files

    10

    Last publish

    Collaborators

    • tandrewnichols