How can I configure mocha to find all test files in my project directory and not only the test files at the test
folder in the root directory?
currently, I'm using npm scripts in package.json:
"test": "mocha"
and running using the following command:
npm run test
To find all test files in your src
directory, say, then you should be able to use a pattern like this:
mocha "src/**/*.test.js"
...and make sure your test files have a .test.js
file extension so they differ from your other .js
files.
(Note the double quotes around the pattern)
this works for me, finding all test files in all directories except the node_modules
mocha \"./{,!(node_modules)/**/}*.test.js\"
for clarification, this glop expression says:
Take all files which end with .test.js in the current directory - which is the root - or in any subdirectory of the current directory, regardless of depth, except for ones that exists in ./node_modules folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With