aboutsummaryrefslogtreecommitdiff
path: root/test/mocha.js
blob: fb8c3841d87e4c90690b7859b36a4eac49d4b86a (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var fs = require("fs");
var Mocha = require("mocha");
var path = require("path");

// Instantiate a Mocha instance
var mocha = new Mocha({
    timeout: 5000
});
var testDir = __dirname + "/mocha/";

// Add each .js file to the Mocha instance
fs.readdirSync(testDir).filter(function(file) {
    return /\.js$/.test(file);
}).forEach(function(file) {
    mocha.addFile(path.join(testDir, file));
});

module.exports = function() {
    mocha.run(function(failures) {
        if (failures) process.on("exit", function() {
            process.exit(failures);
        });
    });
};