From ece554e58f6ab0bda318bb5857c48fded0a05bcb Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 19 Apr 2016 16:53:49 -0700 Subject: [PATCH] Exit with an error code for failures of node tests --- tests/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/index.js b/tests/index.js index 2db13ab2..67d9abc8 100644 --- a/tests/index.js +++ b/tests/index.js @@ -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); + } }