Skip to content

Commit

Permalink
Merge pull request #10 from intellihr/fail-with-exit-code-1
Browse files Browse the repository at this point in the history
#9 Exit the process with code 1 when Jest fails
  • Loading branch information
KariHe authored Dec 2, 2019
2 parents f98b1e7 + 0465080 commit ce252ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ class ServerlessJestPlugin {
'create:test:test': () =>
BbPromise.bind(this).then(() => createTest(this.serverless, this.options)),
'invoke:test:test': () =>
BbPromise.bind(this).then(() => runTests(this.serverless, this.options, this.config)),
BbPromise.bind(this)
.then(() => runTests(this.serverless, this.options, this.config))
.catch((err) => {
if (err.success === false) {
// This is a successful run but with failed tests
process.exit(1);
}
// Not sure what this is
throw err;
}),
'create:function:create': () =>
BbPromise.bind(this)
.then(() => createFunction(this.serverless, this.options))
Expand Down
8 changes: 7 additions & 1 deletion lib/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const runTests = (serverless, options, conf) =>
process.env['SERVERLESS_TEST_ROOT'] = serverless.config.servicePath;

return runCLI(config, [serverless.config.servicePath])
.then((...success) => resolve(...success))
.then((output) => {
if (output.results.success) {
resolve(output);
} else {
reject(output.results);
}
})
.catch(e => reject(e));
});

Expand Down

0 comments on commit ce252ad

Please sign in to comment.