diff --git a/app/test/api.test.js b/app/test/api.test.js index 5a4d4d6..d57d51e 100644 --- a/app/test/api.test.js +++ b/app/test/api.test.js @@ -77,7 +77,7 @@ describe('API Workflow', () => { const { _id, ...output } = result.at(0) ok(_id) - deepStrictEqual(statusCode, 200) + deepStrictEqual(statusCode, 201) deepStrictEqual(output, customers.find(customer => customer.name === name)) }) diff --git a/test-runner/bin/index.js b/test-runner/bin/index.js index 864a0df..d045ec3 100755 --- a/test-runner/bin/index.js +++ b/test-runner/bin/index.js @@ -18,4 +18,5 @@ const formatter = new Formatter(); const reporter = new Reporter(formatter); const testRunner = new TestRunner(folder, formatter, reporter); -testRunner.runTests(); \ No newline at end of file +const hasError = await testRunner.runTests(); +process.exit(hasError ? 1 : 0) diff --git a/test-runner/bin/test-runner.js b/test-runner/bin/test-runner.js index 09cbca1..51cd16b 100644 --- a/test-runner/bin/test-runner.js +++ b/test-runner/bin/test-runner.js @@ -22,9 +22,10 @@ class TestRunner { for (const file of files) { finished.push(this.runTestFile(file)); } - await Promise.all(finished) + const results = await Promise.all(finished) this.reporter.printSummary(this.tests, this.formatter.calcElapsed(this.startedAt)); + return results.some(result => result === 'error') } @@ -76,8 +77,9 @@ class TestRunner { console.error(err) }) - return new Promise(resolve => cp.once('exit', resolve)).finally(() => { + return new Promise(resolve => cp.once('exit', resolve)).then(() => { this.reporter.updateOutput(this.results, this.formatter); + return this.tests.failing > 0 ? 'error' : 'success' }) } }