serverless-mocha-plugin
serverless-mocha-plugin copied to clipboard
`sls invoke test` is checking for files in `node_modules`
Versions:
serverless: 1.21.1
serverless-mocha-plugin: 1.7.0
Problem:
I just followed the documentation to add tests to my existing serverless project. I use sls invoke test -p .
to run tests and get the following error:
Aruns-MacBook-Pro:aws arunshankar$ sls invoke test -p .
Serverless: Invoke invoke:test
Error --------------------------------------------------
Cannot find module 'nock'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
Error: Cannot find module 'nock'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/arunshankar/layer/integrations/serverless-email-fallback/aws/node_modules/@layerhq/serverless-common/tests/api.spec.js:3:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /Users/arunshankar/layer/integrations/serverless-email-fallback/aws/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/arunshankar/layer/integrations/serverless-email-fallback/aws/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/arunshankar/layer/integrations/serverless-email-fallback/aws/node_modules/mocha/lib/mocha.js:514:10)
at vars.populateService.then.then.then.then (/Users/arunshankar/layer/integrations/serverless-email-fallback/aws/node_modules/serverless-mocha-plugin/index.js:295:19)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
at serverless.service.load.then (/Users/arunshankar/layer/integrations/serverless-email-fallback/aws/node_modules/serverless-mocha-plugin/index.js:206:12)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Forums: forum.serverless.com
Chat: gitter.im/serverless/serverless
Your Environment Information -----------------------------
OS: darwin
Node Version: 6.10.0
Serverless Version: 1.21.1
Am I doing something wrong? Or can I exclude node_modules from my tests?
You are running test from your current directory with option -p .
and in that case it will search also from node_modules. Default directory is tests