-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocha-runner.js
43 lines (36 loc) · 968 Bytes
/
mocha-runner.js
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
36
37
38
39
40
41
42
43
'use strict';
// Dependencies
var fs = require('fs');
var Mocha = require('mocha');
var recursiveReadSync = require('recursive-readdir-sync');
// Determine which tests to run based on argument passed to runner
var args = process.argv.splice(2);
var files;
//Define Mocha
var mocha = new Mocha({
timeout: 60000,
reporter: 'spec',
globals: ['Associations', 'CREATE_TEST_WATERLINE', 'DELETE_TEST_WATERLINE']
});
args.forEach(function (testDir) {
try {
files = recursiveReadSync(testDir);
} catch (err) {
if (err.errno === 34) {
console.log('Path does not exist');
} else {
// something unrelated went wrong, rethrow
throw err;
}
}
});
files.filter(function (file) {
// Only keep the .js files
return file.endsWith('.spec.ts');
}).forEach(function(file){
mocha.addFile(file);
});
// Run unit tests
mocha.run(function (failures) {
process.exit(failures);
});