Skip to content

Commit 29d61d8

Browse files
author
Eric Chan
committed
Exit the process with code 1 when the jest is failed
1 parent 8fc025b commit 29d61d8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ class ServerlessJestPlugin {
8989
.then(() => createTest(this.serverless, this.options)),
9090
'invoke:test:test': () =>
9191
BbPromise.bind(this)
92-
.then(() => runTests(this.serverless, this.options)),
92+
.then(() => runTests(this.serverless, this.options))
93+
.catch((err) => {
94+
if (err.success === false) {
95+
// This is a successful run but with failed tests
96+
process.exit(1);
97+
}
98+
// Not sure what this is
99+
throw err;
100+
}),
93101
'create:function:create': () =>
94102
BbPromise.bind(this)
95103
.then(() => createFunction(this.serverless, this.options))

lib/run-tests.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ const runTests = (serverless, options) => new BbPromise((resolve, reject) => {
2929

3030
return runCLI({ config },
3131
serverless.config.servicePath,
32-
success => resolve(success));
32+
(result) => {
33+
if (result.success) {
34+
resolve(result);
35+
} else {
36+
reject(result);
37+
}
38+
});
3339
});
3440

3541
module.exports = runTests;

0 commit comments

Comments
 (0)