Exit with an error code for failures of node tests

This commit is contained in:
Scott Kyle 2016-04-19 16:53:49 -07:00
parent d5aad959ce
commit ece554e58f
1 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,7 @@ const mockery = require('mockery');
function runTests() {
const RealmTests = require('./js');
const testNames = RealmTests.getTestNames();
let passed = true;
for (let suiteName in testNames) {
console.log('Starting ' + suiteName);
@ -40,12 +41,15 @@ function runTests() {
catch (e) {
console.warn('- ' + testName);
console.error(e.message, e.stack);
passed = false;
}
finally {
RealmTests.runTest(suiteName, 'afterEach');
}
}
}
return passed;
}
if (require.main == module) {
@ -53,5 +57,7 @@ if (require.main == module) {
mockery.warnOnUnregistered(false);
mockery.registerMock('realm', require('..'));
runTests();
if (!runTests()) {
process.exit(1);
}
}