Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sls invoke test is checking for files in node_modules #73

Open
arunshan opened this issue Sep 29, 2017 · 1 comment
Open

sls invoke test is checking for files in node_modules #73

arunshan opened this issue Sep 29, 2017 · 1 comment

Comments

@arunshan
Copy link

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?

@KariHe
Copy link
Contributor

KariHe commented Nov 25, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants