Skip to content

Commit

Permalink
Pull changes from upstream grunt-mocha 0.4.10
Browse files Browse the repository at this point in the history
Closes #15
  • Loading branch information
geekdave committed Feb 2, 2014
1 parent 734d366 commit 3690938
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 207 deletions.
1 change: 0 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
"boss": true,
"eqnull": true,
"node": true,
"es5": true,
"scripturl": true
}
152 changes: 13 additions & 139 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,126 +30,21 @@ module.exports = function(grunt) {
tasks: 'test'
}
},
mocha: {
// runs all html files (except test2.html) in the test dir
// In this example, there's only one, but you can add as many as
// you want. You can split them up into different groups here
// ex: admin: [ 'test/admin.html' ]
all: ['example/test/**/!(test2|testBail).html'],
blanket_mocha : {
test: {
src: ['example/test.html'],
options : {
threshold : 50,
globalThreshold : 65,
log : true,
logErrors: true,
moduleThreshold : 60,
modulePattern : "./src/(.*?)/"
}
}

// Runs 'test/test2.html' with specified mocha options.
// This variant auto-includes 'bridge.js' so you do not have
// to include it in your HTML spec file. Instead, you must add an
// environment check before you run `mocha.run` in your HTML.
test2: {

// Test files
src: ['example/test/test2.html'],
options: {
// mocha options
mocha: {
ignoreLeaks: false,
grep: 'food'
},

reporter: 'Spec',

// Indicates whether 'mocha.run()' should be executed in
// 'bridge.js'
run: true,

timeout: 10000
}
},

// Runs the same as test2 but with URL's
testUrls: {
options: {
// mocha options
mocha: {
ignoreLeaks: false,
grep: 'food'
},

reporter: 'Nyan',

// URLs passed through as options
urls: ['http://localhost:' + port + '/example/test/test2.html'],

// Indicates whether 'mocha.run()' should be executed in
// 'bridge.js'
run: true
}
},

// Test using a custom reporter
testReporter: {
src: ['example/test/test.html', 'example/test/test2.html'],
options: {
mocha: {
ignoreLeaks: false,
grep: 'food'
},
reporter: './example/test/reporter/simple',
run: true
}
},

// Test log option
testLog: {
src: ['example/test/test.html'],
options: {
mocha: {
ignoreLeaks: false,
grep: 'food'
},
log: true
}
},

testDest1: {
// Test files
src: ['example/test/test2.html'],
dest: 'example/test/results/spec.out',
options: {
reporter: 'Spec',
run: true
}
},

// Same as above, but with URLS + Xunit
testDest2: {
options: {
reporter: 'XUnit',

// URLs passed through as options
urls: ['http://localhost:' + port + '/example/test/test2.html'],

run: true
},
dest: 'example/test/results/xunit.out'
},

// Test a failing test with bail: true
testBail: {
src: ['example/test/testBail.html'],
// Bail option
options: {
run: true,
bail: true
}
},

// This test should never run
neverTest: {
src: ['example/test/test.html'],
// Bail option
options: {
run: true
}
}
},

connect: {
testUrls: {
options: {
Expand Down Expand Up @@ -193,27 +88,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-connect');


grunt.task.registerTask('testUrls', ['connect:testUrls', 'mocha:testUrls']);
grunt.task.registerTask('testLog', ['mocha:testLog']);
grunt.task.registerTask('testReporter', ['mocha:testReporter']);
grunt.task.registerTask('testDest', [
'mocha:testDest1',
'connect:testDest',
'mocha:testDest2',
'verifyDestResults'
]);
// WARNING: Running this test will cause grunt to fail after mocha:testBail
grunt.task.registerTask('testBail', ['mocha:testBail', 'mocha:neverTest']);
grunt.task.registerTask('test', [
'mocha:all',
'testUrls',
'testLog',
'testReporter',
'testDest',
'testBail'
]);

// By default, lint and run all tests.
grunt.task.registerTask('default', ['jshint', 'test']);
grunt.task.registerTask('default', ['jshint', 'blanket_mocha']);
};
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ This plugin, however:

## Parent Plugin

This plugin is based on [kmiyashiro/grunt-mocha](https://github.com/kmiyashiro/grunt-mocha) and supports all the
configurations of that plugin. Please see that repo for more options on configuration.
This plugin is based on [kmiyashiro/grunt-mocha](https://github.com/kmiyashiro/grunt-mocha/tree/8e72249b1042a270641633a69725ccf63fa10259) v0.4.10 and supports all the
configurations of that plugin as of that version. Please see that repo for more options on configuration.

Changes from the upstream plugin will be merged periodically.

## Getting Started
This plugin requires Grunt `~0.4.1`
Expand All @@ -40,14 +42,8 @@ grunt.loadNpmTasks('grunt-blanket-mocha');

## Dependencies

* Blanket.js v1.1.5.
* Mocha (see note below)

*Note about Mocha versions:* There is a bug in BlanketJS 1.1.5 which makes it incompatible with Mocha versions greater than 1.12.1.
You have two choices:

1. Use the master version of BlanketJS which has [a fix for this](https://github.com/alex-seville/blanket/pull/356). Then you can use the latest version of Mocha
2. Use Mocha 1.12.1 and BlanketJS 1.1.5.
* Blanket.js (tested with v1.1.5)
* Mocha (tested with v1.14.0)

## The "blanket_mocha" task

Expand All @@ -69,9 +65,11 @@ In your project's Gruntfile, add a section named `blanket_mocha` to the data obj
```js
grunt.initConfig({
blanket_mocha: {
all: [ 'specs/index.html' ],
options: {
threshold: 70
test: {
src: ['specs/test.html'],
options : {
threshold : 70
}
}
}
})
Expand Down Expand Up @@ -245,6 +243,11 @@ In lieu of a formal styleguide, take care to maintain the existing coding style.

## Release History

## 0.4.0
*Released 2 February 2014*

* Pull upstream changes from grunt-mocha 0.4.10

### 0.3.4
*Released 31 January 2014*

Expand Down
24 changes: 15 additions & 9 deletions example/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
/*global module*/
module.exports = function(grunt) {"use strict";
module.exports = function(grunt) {

"use strict";

grunt.initConfig({

blanket_mocha : {
all : ['test.html'],
options : {
threshold : 50,
globalThreshold : 65,
log : true,
moduleThreshold : 60,
modulePattern : "./src/(.*?)/"
blanket_mocha : {
test: {
src: ['test.html'],
options : {
threshold : 50,
globalThreshold : 65,
log : true,
logErrors: true,
moduleThreshold : 60,
modulePattern : "./src/(.*?)/"
}
}

}
});

Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"node": ">= 0.8.0"
},
"devDependencies": {
"grunt-blanket-mocha": "0.3.4",
"grunt-blanket-mocha": "~0.4.0",
"grunt": "0.4.1",
"mocha": "1.17.1",
"chai": "1.8.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-blanket-mocha",
"description": "Headless Blanket.js code coverage and Mocha testing via PhantomJS",
"version": "0.3.4",
"version": "0.4.0",
"homepage": "https://github.com/ModelN/grunt-blanket-mocha",
"author": {
"name": "Dave Cadwallader",
Expand Down
3 changes: 2 additions & 1 deletion phantomjs/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

// Create a listener who'll bubble events from Phantomjs to Grunt
function createGruntListener(ev, runner) {

runner.on(ev, function(test, err) {
var data = {
err: err
Expand All @@ -32,6 +33,7 @@
}

sendMessage('mocha.' + ev, data);

});
}

Expand Down Expand Up @@ -68,7 +70,6 @@

var GruntReporter = function(runner){

var GruntReporter = function(runner){
if (!mochaInstance) {
throw new Error('Mocha was not found, make sure you include Mocha in your HTML spec file.');
}
Expand Down

0 comments on commit 3690938

Please sign in to comment.