My directory follows this structure:
src
/test
- file-test.js
- file.js
My Mocha script uses
mocha -R spec --recursive ./**/*-test.js
Which leads to the fantastical error of Error: Cannot find module 'tap'
.
But peculiarly the following two options work
mocha -R spec --recursive ./src/**/*-test.js
file-test.js
to file.test.js
and using mocha -R spec --recursive ./**/*.test.js
But I have no idea why those two options work, and my original plan did not.
Maybe this is a long shot, but the glob pattern must be between double quotes if this is an npm script: mocha -R spec --recursive "./**/*-test.js"
. I had a similar error with mocha.
I know this is a while back, but I've had a similar issue, if you specify a matching file pattern eg. src/**/*.spec.js
then --recursive
is apparently redundant https://stackoverflow.com/a/43005752
The above comment about escaping the path because npm uses "" double quotes should be correct I believe.
So instead of something like this:
mocha --recursive ./**/*-test.js
This worked for me:
mocha \"./**/*-test.js\"
Hope that helped..
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