Created
May 1, 2013 08:58
-
-
Save neilmanuell/5494389 to your computer and use it in GitHub Desktop.
Mocha test runner for use with NodeJS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Mocha = require('mocha'), | |
path = require('path'), | |
fs = require('fs'); | |
var mocha = new Mocha({ | |
reporter: 'dot', | |
ui: 'bdd', | |
timeout: 999999 | |
}); | |
var testDir = './test/'; | |
fs.readdir(testDir, function (err, files) { | |
if (err) { | |
console.log(err); | |
return; | |
} | |
files.forEach(function (file) { | |
if (path.extname(file) === '.js') { | |
console.log('adding test file: %s', file); | |
mocha.addFile(testDir + file); | |
} | |
}); | |
var runner = mocha.run(function () { | |
console.log('finished'); | |
}); | |
runner.on('pass', function (test) { | |
console.log('... %s passed', test.title); | |
}); | |
runner.on('fail', function (test) { | |
console.log('... %s failed', test.title); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
taken unedited from @ronderksen (twitter) originally here