Skip to content

Commit

Permalink
add error case for CI
Browse files Browse the repository at this point in the history
Signed-off-by: Erick Wendel <erick.workspace@gmail.com>
  • Loading branch information
ErickWendel committed Dec 7, 2024
1 parent 5cecea2 commit 9dd6718
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

Expand Down
3 changes: 2 additions & 1 deletion test-runner/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ const formatter = new Formatter();
const reporter = new Reporter(formatter);
const testRunner = new TestRunner(folder, formatter, reporter);

testRunner.runTests();
const hasError = await testRunner.runTests();
process.exit(hasError ? 1 : 0)
6 changes: 4 additions & 2 deletions test-runner/bin/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

}

Expand Down Expand Up @@ -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'
})
}
}
Expand Down

0 comments on commit 9dd6718

Please sign in to comment.