grunt-mocha integration

This commit is contained in:
Spencer Alger 2015-06-15 16:05:30 -07:00
parent 1b308bf86b
commit 4579019ec1
2 changed files with 53 additions and 57 deletions

View file

@ -54,15 +54,19 @@
urlArgs: COVERAGE ? 'instrument=true' : void 0
});
mocha.setup({
ui: 'bdd',
timeout: 5000,
reporter: 'html'
});
function setupMocha() {
require(['lodash'], function (_) {
require(['lodash', 'jquery'], function (_, $) {
$(function () {
mocha.ui = _.wrap(mocha.ui, function (mochaUi, ui) {
var ret = mochaUi.call(this, ui);
var oldDescribe = window.describe;
window.describe = _.wrap(oldDescribe, unwindDescribeArrays);
window.describe.only = _.wrap(oldDescribe.only, unwindDescribeArrays);
var _desc = window.describe;
window.describe = _.wrap(_desc, unwindDescribeArrays);
window.describe.only = _.wrap(_desc.only, unwindDescribeArrays);
function unwindDescribeArrays(fn, name, body) {
if (!body && name && name instanceof Array) {
body = name[1]; name = name[0];
@ -71,18 +75,9 @@
return fn.call(this, name, body);
}
return ret;
});
mocha.setup({
ui: 'bdd',
timeout: 5000,
reporter: 'html'
});
if (COVERAGE) setupCoverage(runTests);
else runTests();
if (COVERAGE) setupCoverage(runTests);
else runTests();
})
});
}

File diff suppressed because one or more lines are too long