grunt-simple-mocha
Version:
A simple wrapper for running tests with Mocha.
35 lines (26 loc) • 913 B
JavaScript
/*
* grunt-simple-mocha
* https://github.com/yaymukund/grunt-simple-mocha
*
* Copyright (c) 2012 Mukund Lakshman
* Licensed under the MIT license.
*/
;
module.exports = function(grunt) {
var path = require('path'),
Mocha = require('mocha');
grunt.registerMultiTask('simplemocha', 'Run tests with mocha', function() {
var options = this.options(),
mocha_instance = new Mocha(options);
this.filesSrc.forEach(mocha_instance.addFile.bind(mocha_instance));
// We will now run mocha asynchronously and receive number of errors in a
// callback, which we'll use to report the result of the async task by
// calling done() with the appropriate value to indicate whether an error
// occurred.
var done = this.async();
mocha_instance.run(function(errCount) {
var withoutErrors = (errCount === 0);
done(withoutErrors);
});
});
};