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

grunt-mocha-cov

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-mocha-cov

Run Mocha server-side tests in Grunt with code coverage support and optional integration to coveralls.io.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55
decreased by-27.63%
Maintainers
1
Weekly downloads
 
Created
Source

Grunt Mocha Test Coverage Build Status

Use Grunt to execute server-side Mocha tests with optional code coverage using Blanket. You can also use this to send coverage data to Coveralls.

This is based on grunt-mocha-cli and can be used in place of this library with support for running code coverage reports or integration into Coveralls.

Getting Started

You can install this plugin with this command:

npm install grunt-mocha-cov --save-dev

Note: This is a grunt plugin. If you haven't used Grunt before, check out their Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins.

Usage

Options

All of the Mocha command line options are supported, plus some extras.

The list of test files to run can be specified using either the standard Grunt format or by using the files option. If neither is specified, the Mocha default will be used (test/*.js).

Mocha Options
  • invert (boolean) - inverts grep matches.
  • colors (boolean) - force enabling of colors.
  • no-colors (boolean) - force disabling of colors.
  • growl (boolean) - enable growl notification support.
  • debug (boolean) - enable node's debugger, synonym for node --debug.
  • bail (boolean) - bail after first test failure.
  • recursive (boolean) - include sub directories.
  • debug-brk (boolean) - enable node's debugger breaking on the first line.
  • ignore-leaks (boolean) - ignore global variable leaks.
  • reporter (string) - specify the reporter to use.
  • ui (string) - specify user-interface (bdd|tdd|exports).
  • grep (string) - only run tests matching pattern.
  • timeout (string) - set test-case timeout in milliseconds [2000].
  • slow (string) - "slow" test threshold in milliseconds [75].
  • globals (array) - allow the given comma-delimited global names.
  • compilers (array) - use the given module(s) to compile files.
Coverage Options
  • coverage (boolean) - instrument the source using blanket. This will automaticaly be enabled if you configure coveralls.
Coveralls Options
  • coveralls (Object) - indicate you wish to instrament your test and send coverage reports to coveralls.io
    • serviceName (string) - name of the CI service for coveralls to integrate with (ie: travis-pro).
    • serviceJobId (string) - The job id used by coveralls (default: process.env.TRAVIS_JOB_ID).
    • repoToken (string) - repository identifier as provided by coveralls.
Extras
  • quiet (boolean) - disable printing of Mocha's output to the terminal.
  • files (string|array) - glob(s) of test files to run.

Examples

Standard Mocha Test

Define test files using the standard Grunt format:

grunt.initConfig({
  mochacov: {
    options: {
      reporter: 'spec',
      require: ['should']
    },
    all: ['test/*.js']
  }
});

grunt.registerTask('test', ['mochacov']);
Built in HTML Coverage Report

If you use one of the built in built in coverage reports your code will automaticaly be instrumented by blanket:

grunt.initConfig({
  mochacov: {
    options: {
      reporter: 'html-cov',
      require: ['should']
    },
    all: ['test/*.js']
  }
});

grunt.registerTask('test', ['mochacov']);
Coveralls.io Integration with Travis CI

It's easy to send coverage data to coveralls.io from Travis CI. Simply provided the coveralls option with relavent params and that's it:

grunt.initConfig({
  mochacov: {
    coverage: {
      options: {
        coveralls: {
          serviceName: 'travis-pro',
          repoToken: '<your-coveralls-token-here>'
        },
      }
    },
    test: {
      options: {
        reporter: 'spec'
      }
    },
    options: {
      files: 'test/*.js'
    }
  }
});

grunt.registerTask('travis', ['mochacov:coverage']);
grunt.registerTask('test', ['mochacov:test']);

License

Grunt Mocha Coveralls is based on original works by Gregg Caines and Roland Warmerdam. Modifications and new works by Mike Moulton released under the MIT license.

Copyright © 2013 Mike Moulton

Keywords

FAQs

Package last updated on 17 Apr 2013

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