nordcloud/serverless-mocha-plugin

--exit flag causes process always to exit with code 0

esteban-angee opened this issue · 0 comments

Description

I have the following basic test:

describe('Get Settlement Transactions', () => {
    it('Should exit with code 1', async () => {
        throw Error('An error')
      })
})

Then I'm running:
serverless invoke test --exit --compilers js:babel-core/register && echo $?

What happened

My test evidently fails but the exit code is always 0. This is obviously killing my CI setup


  First test
    1) Should exit with code 1


  0 passing (21ms)
  1 failing

  1) First test
       Should exit with code 1:
     Error: An error
      at _callee$ (test/integration/getSettlementTransactions.js:140:11)
      at tryCatch (node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:296:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:114:21)
      at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
      at new Promise (<anonymous>)
      at new F (node_modules/core-js/library/modules/_export.js:36:28)
      at Context.<anonymous> (node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
      at process.topLevelDomainCallback (domain.js:121:23)



✨  Done in 2.38s.
0

What should have happened

Exit code should have been 1

Additional details

OS:
MacOS High Sierra

Serverless version:
1.32.0

Plugin version:
1.9.0

Related Issues:
#92

EDIT: If I remove the --exit flag the exit code is 1