0

I am using GitLab's serverless framework template and trying to run tests locally first, by creating a child serverless offline process. I am getting the error 'spawn serverless ENOENT' when executing the jest tests. Any idea why?

let useLocalService = true
...
let serverlessProcess = {
  serverless_process: null,
  start: async () => {
    if(useLocalService) {
      this.serverless_process = spawn('serverless', ['offline', '--port', 3000])
    }
  },
  stop: () => {
    if(useLocalService) {
      this.serverless_process.kill('SIGINT')
    }
  }
}
describe('hello', () => {
  beforeAll(async () => {
    // serverlessProcess.start starts serverless offline in a child process
    // unless the test is pointed at a deployed service
    await serverlessProcess.start()
  })

  afterAll(() => {
    // serverlessProcess.stop kills the child process at the end of the test
    // unless the test is pointed at a deployed service
    serverlessProcess.stop()
  })

  it(...

The only error message I recieve:

  ● Test suite failed to run

    spawn serverless ENOENT
jk_77
  • 1
  • 1

1 Answers1

0

Are your trying to initiate any AWS service locally?

If you are trying to use any AWS plugins that is causing the error.

  1. Make sure Java is installed
  2. setup AWS service which you are trying locally eg: if dynamodb then sls dynamodb install

If you still face issue then check serverless local issue by enabling DEBUG export SLS_DEBUG=true