Skip to content

Commit 9a8a8d7

Browse files
committed
first step at getting rid of mocha/embark on package.json
1 parent 88c1a16 commit 9a8a8d7

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

lib/cmd.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ class Cmd {
139139
.command('test')
140140
.description('run tests')
141141
.action(function () {
142-
shelljs.exec('mocha test');
142+
embark.initConfig('development', {
143+
embarkConfig: 'embark.json', interceptLogs: false
144+
});
145+
embark.runTests();
146+
//shelljs.exec('mocha test');
143147
});
144148
}
145149

lib/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,34 @@ class Embark {
195195
}
196196
}
197197

198+
runTests() {
199+
var Mocha = require('mocha'),
200+
fs = require('fs'),
201+
path = require('path');
202+
203+
var mocha = new Mocha();
204+
205+
var testDir = 'test/';
206+
207+
// Add each .js file to the mocha instance
208+
fs.readdirSync(testDir).filter(function(file){
209+
// Only keep the .js files
210+
return file.substr(-3) === '.js';
211+
212+
}).forEach(function(file){
213+
mocha.addFile(
214+
path.join(testDir, file)
215+
);
216+
});
217+
218+
// Run the tests.
219+
mocha.run(function(failures){
220+
process.on('exit', function () {
221+
process.exit(failures); // exit with non-zero status if there were failures
222+
});
223+
});
224+
}
225+
198226
}
199227

200228
// temporary until next refactor

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"fs-extra": "^2.0.0",
2727
"globule": "^1.1.0",
2828
"merge": "^1.2.0",
29+
"mocha": "^2.2.5",
2930
"promptly": "^2.1.0",
3031
"serve-static": "^1.11.1",
3132
"shelljs": "^0.5.0",

0 commit comments

Comments
 (0)