Skip to content

Commit

Permalink
Merge pull request #40 from mmoulton/develop
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
mmoulton committed Mar 24, 2015
2 parents 5cf8196 + 9bfa38b commit d251763
Show file tree
Hide file tree
Showing 12 changed files with 644 additions and 348 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
node_modules
/npm-debug.log
26 changes: 6 additions & 20 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
language: node_js
node_js:
- '0.10'
script: './node_modules/.bin/grunt travis'
- '0.12'

script: 'grunt test'

matrix:
fast_finish: true

sudo: false
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

* Updating all dependencies, this includes:
* mocha 0.14.x
* blanket 1.1.5
* blanket 1.1.6
* Changed search location for `mocha` (resolved #17)

### 0.1.1 (Dec 6, 2013)
Expand All @@ -50,3 +50,21 @@

* Updated coffeescript dependency for mocha tests to use 1.7.x where you now must explicitly register the compiler
* Fixed typos

### 0.3.0 (Aug 4, 2014)

* Updating all dependencies, this includes:
* mocha 1.21.3
* blanket 1.1.6
* coveralls 2.11.1
* Support for latest mocha options, including Harmony mode (Thanks @jan-molak)

### 0.4.0 (Mar 24, 2015)

* Node 0.12.x / io 1.x support
* Updating dependencies
* mocha 2.2.1
* coveralls 2.11.2
* Fix #38

** Thanks to @xhmikosr for the PR that made this possible
7 changes: 3 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
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
73 changes: 47 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -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,54 +15,71 @@ 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.
* `growl` (boolean) - enable growl notification support.
* `debug` (boolean) - enable node's debugger, synonym for node --debug.
* `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.
* `async-only` (boolean) - force all tests to take a callback (async).
* `check-leaks` (boolean) - check for global variable leaks.
* `sort` (boolean) - sort test files.
* `inline-diffs` (boolean) - display actual/expected differences inline within each string.
* `no-exit` (boolean) - require a clean shutdown of the event loop: mocha will not call `process.exit()`.
* `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.
* `require` (array) - require the given modules.
* `expose-gc` (boolean) - expose gc extension, synonym for `node --expose-gc`.
* `gc-global` (boolean) - always perform global GCs, synonym for `node --gc-global`.
* `harmony` (boolean) - enable all harmony features (except typeof), synonym for `node --harmony`.
* `harmony-proxies` (boolean) - enable harmony proxies, synonym for `node --harmony-proxies`.
* `harmony-collections` (boolean) - enable harmony collections, synonym for `node --harmony-collections`.
* `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 @@ -76,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 @@ -107,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 @@ -134,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 @@ -151,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 @@ -177,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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright(c) 2013 Mike Moulton <[email protected]>
* MIT Licensed
*/

'use strict';


Expand Down
19 changes: 15 additions & 4 deletions lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright(c) 2013 Mike Moulton <[email protected]>
* MIT Licensed
*/

'use strict';

var grunt = require('grunt'),
Expand All @@ -26,7 +27,18 @@ var BOOL_OPTIONS = [
'bail',
'recursive',
'debug-brk',
'ignore-leaks'
'async-only',
'check-leaks',
'sort',
'inline-diffs',
'no-exit',
'expose-gc',
'gc-global',
'harmony',
'harmony-proxies',
'harmony-collections',
'harmony-generators',
'prof'
];
var STRING_OPTIONS = [
'reporter',
Expand Down Expand Up @@ -80,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
Loading

0 comments on commit d251763

Please sign in to comment.