1

I have the following folder structure:

  • app
    • lambda
      • users
        • handler.js
      • companies
        • handler.js
  • tests
    • mocha.opts
    • package.lock.json
    • package.json
    • lambda
      • users
        • handler.test.js
        • helper.js
      • companies
        • handler.test.js
        • fixture.js

When I run the 'npm test' from the following location

C:\myproject\tests> npm test

I get the following warning because it cannot find the tests to be run.

Warning: Could not find any test files matching pattern: test
No test files found
npm ERR! Test failed. See above for more details.

How can I configure it to tell Mocha to run only all my 'handler.test.js' files?

I have this on my package.json

"scripts": { "test": "mocha './lambda/**/*.test.js'"} 

I would expect that to work, but it is not finding the tests files.

0

1 Answer 1

3

How can I configure it to tell Mocha to run only all my 'handler.test.js' files?

Try this:

"scripts": { "test": "mocha tests/lambda/**/*.test.js --recursive" } 
Sign up to request clarification or add additional context in comments.

2 Comments

I am not using nodemon. And 'mocha --recursive' will not work for me. Thanks
You were under something. The following works for me: "mocha ./lambda/**/*.test.js --recursive"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.