mardi 1 janvier 2019

Testing serverless with Mocha plugin

I have been using serverless for a while now, however this is the first time I'm trying to use mocha for writing tests. When I'm trying to run the following sls create test --function insiders/create.create I get the following error Cannot read property 'handler' of undefined. This is how my serverless.yml looks like for the handler I have created

createInsider:
    handler: insiders/create.create
    events:
      - http:
          path: insiders
          method: post
          cors: true

This is how the plugin Mocha is defined

plugins:
  - serverless-mocha-plugin

The code is deployed and it works fine. The namespacing is as insiders/create.js is where I have defined my function.

module.exports.create = () => {}

I have also tried the following ways

sls create test --function insiders/create

sls create test --function create

Aucun commentaire:

Enregistrer un commentaire