Skip to content

Commit 9dd6718

Browse files
committed
add error case for CI
Signed-off-by: Erick Wendel <[email protected]>
1 parent 5cecea2 commit 9dd6718

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

app/test/api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('API Workflow', () => {
7777
const { _id, ...output } = result.at(0)
7878
ok(_id)
7979

80-
deepStrictEqual(statusCode, 200)
80+
deepStrictEqual(statusCode, 201)
8181
deepStrictEqual(output, customers.find(customer => customer.name === name))
8282
})
8383

test-runner/bin/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ const formatter = new Formatter();
1818
const reporter = new Reporter(formatter);
1919
const testRunner = new TestRunner(folder, formatter, reporter);
2020

21-
testRunner.runTests();
21+
const hasError = await testRunner.runTests();
22+
process.exit(hasError ? 1 : 0)

test-runner/bin/test-runner.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ class TestRunner {
2222
for (const file of files) {
2323
finished.push(this.runTestFile(file));
2424
}
25-
await Promise.all(finished)
25+
const results = await Promise.all(finished)
2626

2727
this.reporter.printSummary(this.tests, this.formatter.calcElapsed(this.startedAt));
28+
return results.some(result => result === 'error')
2829

2930
}
3031

@@ -76,8 +77,9 @@ class TestRunner {
7677
console.error(err)
7778
})
7879

79-
return new Promise(resolve => cp.once('exit', resolve)).finally(() => {
80+
return new Promise(resolve => cp.once('exit', resolve)).then(() => {
8081
this.reporter.updateOutput(this.results, this.formatter);
82+
return this.tests.failing > 0 ? 'error' : 'success'
8183
})
8284
}
8385
}

0 commit comments

Comments
 (0)