Skip to content

TypeError: Cannot read property 'handler' of undefined #143

Open
@thg303

Description

@thg303

I install the plugin using:
serverless plugin install --name serverless-mocha
when I try to create a function like this:
sls create function -f testFunction --handler src/functions/testFunction.testFunction -p src/tests/

I get the following result:

Serverless: Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
             - mochaPlugin for "function", "path", "handler", "httpEvent", "reporter", "reporter-options", "grep", "live", "root", "compilers", "timeout", "exit"
            Please report this issue in plugin issue tracker.
            Starting with next major release, this will be communicated with a thrown error.
            More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_SCHEMA
Serverless: Generating function...
Serverless: Created function file "/Users/ali/projects/serverless-crm/src/functions/testFunction.js"

 Type Error ----------------------------------------------

  TypeError: Cannot read property 'handler' of undefined
      at mochaPlugin.createTest (/Users/ali/projects/serverless-crm/node_modules/serverless-mocha/index.js:367:31)
      at PluginManager.invoke (/Users/ali/.nvm/versions/node/v14.16.1/lib/node_modules/serverless/lib/classes/PluginManager.js:551:20)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.16.1
     Framework Version:         2.35.0
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.8.3

It creates the function file at src/functions/testFunction.testFunction.js but the serverless.yaml file changes are:

  undefined:
    handler: src/functions/testFunction.testFunction

and no test file is generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions