-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrunner.js
More file actions
35 lines (31 loc) · 736 Bytes
/
runner.js
File metadata and controls
35 lines (31 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var fs = require('fs'),
Mocha = require("mocha"),
path = require('path');
// Our Mocha runner
var mocha = new Mocha({
ui:"bdd",
reporter:"spec",
timeout:5000,
slow:1000
});
// Files which need to be ignored
var avoided = [
"node_modules"
];
// Add the tests to the Mocha instance
(addFiles = function(dir){
fs.readdirSync(dir).filter(function(file){
if(!~avoided.indexOf(file)){
if(fs.statSync(dir + '/' + file).isDirectory()){
addFiles(dir + '/' + file);
}
return file.substr(-3) === '.js';
}
}).forEach(function(file){
mocha.addFile(dir + '/' + file);
});
})(path.join(process.cwd(), process.argv[2] || "."));
// Run the files in Mocha
mocha.run(function(failures){
process.exit(failures);
});