I am using mocha for testing. I am running mocha with a recursive glob pattern (./src/**/*.test.ts) to run all my tests, but only some of them are executed. Particularly only my tests under src/utils are being run. If I give mocha ./src/handlers/**/*.test.ts as the path the tests do execute under src/handlers, but obviously this is not ideal.
I have done some refactoring on my code and before that it worked fine.
What am I doing wrong?
My project structure looks like this:
src
|-handlers
| |-Connection
| |-tests
| |- handleConnection.test.ts
| |- handleDisconnection.test.ts
| |...
|-utils
|-utils.test.ts
|...
I am trying to run mocha with this npm script:
"test": "mocha ./src/**/*.test.ts -r ts-node/register"
After digging around some more I have solved my issue by putting the glob pattern between single quotes:
"test": "mocha './src/**/*.test.ts' -r ts-node/register"
Apparently without putting it between quotes some systems can interpret ** as *: How can mocha recursively search my `src` folder for a specific filename pattern?
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