Skip to content

Commit

Permalink
Merge 2438014 into 096f617
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 14, 2015
2 parents 096f617 + 2438014 commit f496521
Show file tree
Hide file tree
Showing 11 changed files with 437 additions and 292 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
.DS_Store
node_modules
/npm-debug.log
26 changes: 6 additions & 20 deletions .jshintrc
@@ -1,36 +1,22 @@
{
"globals": {
"describe": false,
"it": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false
},

"node" : true,

"bitwise": true,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"forin": true,
"immed": true,
"indent": 2,
"latedef": false,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"plusplus": true,
"indent": 2,
"quotmark": true,
"regexp": true,
"undef": true,
"unused": true,
"quotmark": "single",
"strict": true,
"trailing": true,

"eqnull": true,

"white": true
}
"undef": true,
"unused": true
}
7 changes: 6 additions & 1 deletion .travis.yml
@@ -1,4 +1,9 @@
language: node_js
node_js:
- '0.10'
script: './node_modules/.bin/grunt travis'
- '0.12'

script: 'grunt travis'

matrix:
fast_finish: true
7 changes: 3 additions & 4 deletions Gruntfile.js
Expand Up @@ -7,10 +7,9 @@ module.exports = function (grunt) {
jshintrc: '.jshintrc'
},
all: [
'.jshintrc',
'package.json',
'**/*.js',
'!node_modules/**/*'
'lib/*.js',
'tasks/*.js',
'tests/*.js'
]
},

Expand Down
57 changes: 33 additions & 24 deletions README.md
@@ -1,12 +1,12 @@
# Grunt Mocha Test Coverage [![Build Status][travis-image]][travis] [![Coverage Status][coveralls-image]][coveralls]
# Grunt Mocha Test Coverage
[![Build Status][travis-image]][travis] [![Coverage Status][coveralls-image]][coveralls] [![Dependency Status][david-image]][david] [![devDependency Status][david-dev-image]][david-dev]

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
---------------
## Getting Started
You can install this plugin with this command:

```bash
Expand All @@ -15,15 +15,17 @@ 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 ###
## 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 ####
#### Mocha Options

* `invert` (boolean) - inverts `grep` matches.
* `colors` (boolean) - force enabling of colors.
* `no-colors` (boolean) - force disabling of colors.
Expand Down Expand Up @@ -53,28 +55,31 @@ The list of test files to run can be specified using either the standard Grunt f
* `harmony-generators` (boolean) - enable harmony generators, synonym for `node --harmony-generators`.
* `prof` (boolean) - log statistical profiling information, synonym for `node --prof`.

#### Coverage Options ####
#### Coverage Options

* `instrument` (boolean) - instrument the source using blanket. Defaults to true when you setup `coveralls`, or use specify a `*-cov` reporter, otherwise false.

#### Coveralls Options ####
#### Coveralls Options

* `coveralls` (Boolean|Object) - Indicate you wish to send a coverage report to coveralls.io. ***Generally*** you can get away with seting this to `true` and letting [node-coveralls](https://github.com/cainus/node-coveralls) pick the necessary values out of the environment.
* `serviceName` (string) - name of the CI service for coveralls to integrate with (options are `travis-ci`, `jenkins`, `circleci`, or `codeship`).
* `serviceJobId` (string) - The job id used by coveralls (default based on service).
* `repoToken` (string) - repository identifier as provided by coveralls (defaults to the `COVERALLS_REPO_TOKEN` environment variable).

#### Extras ####
#### Extras

* `quiet` (boolean) - disable printing of Mocha's output to the terminal.
* `files` (string|array) - glob(s) of test files to run.
* `output` (string) - path to save report to disk.


### Examples ###
### Examples

#### Standard Mocha Test ####
#### Standard Mocha Test

Define test files using the standard Grunt format:

```javascript
```js
grunt.initConfig({
mochacov: {
options: {
Expand All @@ -88,11 +93,11 @@ grunt.initConfig({
grunt.registerTask('test', ['mochacov']);
```

#### Built in HTML Coverage Report ####
#### Built in HTML Coverage Report

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

```javascript
```js
grunt.initConfig({
mochacov: {
options: {
Expand All @@ -119,11 +124,11 @@ For this to work properly you will also need to inform [Blanket][] about what ne
```
This would instrument any .js files found under `src`.

#### Coveralls.io Integration with Travis CI ####
#### Coveralls.io Integration with Travis CI

It's easy to send coverage data to coveralls.io from the most popular CI serivces (like Travis CI). Simply set the `coveralls` option to true:

```javascript
```js
grunt.initConfig({
mochacov: {
coverage: {
Expand All @@ -146,7 +151,7 @@ grunt.registerTask('travis', ['mochacov:coverage']);
grunt.registerTask('test', ['mochacov:test']);
```

#### Keep your Coveralls repo token out of the environment ####
#### Keep your Coveralls repo token out of the environment

Don't want to keep your repo token in the environment where anyone could access it? Pass it in via the `coveralls.repoToken` option:

Expand All @@ -163,11 +168,11 @@ grunt.initConfig({
})
```

#### Setup intrumentation yourself ####
#### Setup intrumentation yourself

If you want to start blanket yourself, as in [this example](https://github.com/alex-seville/blanket/blob/master/docs/intermediate_node.md), just set the `instrument` option to false.

```javascript
```js
grunt.initConfig({
mochacov: {
options: {
Expand All @@ -189,13 +194,17 @@ Modifications and new works by Mike Moulton released under the MIT license.
Copyright © 2013 Mike Moulton


[Mocha]: http://visionmedia.github.com/mocha/
[Mocha]: http://mochajs.org/
[Grunt]: http://gruntjs.com/
[Blanket]: http://blanketjs.org/
[Coveralls]: https://coveralls.io
[Getting Started]: http://gruntjs.com/getting-started
[grunt-mocha-cli]: https://github.com/Rowno/grunt-mocha-cli
[travis]: http://travis-ci.org/mmoulton/grunt-mocha-cov
[travis-image]: https://secure.travis-ci.org/mmoulton/grunt-mocha-cov.png?branch=master
[travis]: https://travis-ci.org/mmoulton/grunt-mocha-cov
[travis-image]: https://img.shields.io/travis/mmoulton/grunt-mocha-cov/master.svg?style=flat
[coveralls]: https://coveralls.io/r/mmoulton/grunt-mocha-cov
[coveralls-image]: https://coveralls.io/repos/mmoulton/grunt-mocha-cov/badge.png?branch=master
[coveralls-image]: https://img.shields.io/coveralls/mmoulton/grunt-mocha-cov/master.svg?style=flat
[david]: https://david-dm.org/mmoulton/grunt-mocha-cov
[david-image]: https://img.shields.io/david/mmoulton/grunt-mocha-cov.svg?style=flat
[david-dev]: https://david-dm.org/mmoulton/grunt-mocha-cov#info=devDependencies
[david-dev-image]: https://img.shields.io/david/dev/mmoulton/grunt-mocha-cov.svg?style=flat
1 change: 1 addition & 0 deletions lib/instrument.js
Expand Up @@ -3,6 +3,7 @@
* Copyright(c) 2013 Mike Moulton <mike@meltmedia.com>
* MIT Licensed
*/

'use strict';


Expand Down
6 changes: 3 additions & 3 deletions lib/mocha.js
Expand Up @@ -3,6 +3,7 @@
* Copyright(c) 2013 Mike Moulton <mike@meltmedia.com>
* MIT Licensed
*/

'use strict';

var grunt = require('grunt'),
Expand Down Expand Up @@ -91,14 +92,13 @@ function getBaseOptions(options) {

if (typeof options.require === 'string') {
options.require = [options.require];
}
else if (!Array.isArray(options.require)) {
} else if (!Array.isArray(options.require)) {
options.require = [];
}

// Instrument the source with blanket
if (options.instrument) {
options.require.push(path.relative(process.cwd(), __dirname + '/instrument'));
options.require.push(path.relative(process.cwd(), path.join(__dirname, '/instrument')));
}

return options;
Expand Down

0 comments on commit f496521

Please sign in to comment.