-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_script.js
More file actions
31 lines (25 loc) · 819 Bytes
/
test_script.js
File metadata and controls
31 lines (25 loc) · 819 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
const Mocha = require('mocha'),
fs = require('fs'),
path = require('path');
const meteor = require('child_process').spawn('meteor',[],{cwd:'./test/server'});
// Instantiate a Mocha instance.
const mocha = new Mocha();
const testDir = './test'
// Add each .js file to the mocha instance
fs.readdirSync(testDir).filter(function(file){
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function(file){
mocha.addFile(
path.join(testDir, file)
);
});
meteor.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
if (data.indexOf('App running at: http://localhost:3000/')>-1) {
mocha.run(function(failures){
meteor.kill('SIGINT');
process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures
});
}
});