Skip to content

Commit

Permalink
Merge pull request jshint#1597 from dalsgaard/2.x
Browse files Browse the repository at this point in the history
Added support for the Mocha test framework
  • Loading branch information
valueof committed Mar 30, 2014
2 parents 0c0e193 + bcbb740 commit 10ea5f7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ var JSHINT = (function () {
wsh : true, // if the Windows Scripting Host environment globals
// should be predefined
yui : true, // YUI variables should be predefined
mocha : true, // Mocha functions should be predefined
noyield : true, // allow generators without a yield

// Obsolete options
Expand Down Expand Up @@ -399,6 +400,10 @@ var JSHINT = (function () {
combine(predefined, vars.yui);
}

if (state.option.mocha) {
combine(predefined, vars.mocha);
}

// Let's assume that chronologically ES3 < ES5 < ES6/ESNext < Moz

state.option.inMoz = function (strict) {
Expand Down
14 changes: 14 additions & 0 deletions src/vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,17 @@ exports.yui = {
YUI_config: false
};

exports.mocha = {
// BDD
describe : false,
it : false,
before : false,
after : false,
beforeEach : false,
afterEach : false,
// TDD
suite : false,
test : false,
setup : false,
teardown : false
};
20 changes: 20 additions & 0 deletions tests/unit/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,23 @@ exports.phantom = function (test) {

test.done();
};

exports.mocha = function (test) {
var globals = [
'describe',
'it',
'before',
'after',
'beforeEach',
'afterEach',
'suite',
'test',
'setup',
'teardown'
];

globalsImplied(test, globals);
globalsKnown(test, globals, { mocha: true });

test.done();
};

0 comments on commit 10ea5f7

Please sign in to comment.