mochajs / mocha

☕️ simple, flexible, fun javascript test framework for node.js & the browser
https://mochajs.org
MIT License
22.59k stars 3.01k forks source link

🐛 Bug: Option "--recursive" does not support typescript files #4186

Open fedulovivan opened 4 years ago

fedulovivan commented 4 years ago

If we need to grab all *.ts files from certain directory the only workaround is usage of bash globstar option:

mocha "./test/**/*.ts"

Following is not working:

mocha --recursive "./test/*.ts"

Note, that for *.js files both are working well:

mocha "./test/**/*.js"
mocha --recursive "./test/*.js"

Tested with latest 6.* version v6.2.2

juergba commented 4 years ago

Yes, you are correct.--recursive is not working as expected.

Currently it's working only for directories:

You can set the extensions via CLI --extension or via configuration file.

Unfortunately our dependency glob does not offer any option for walking subdirectories, except the globstar **. So there is no trivial fix for this issue.

fedulovivan commented 4 years ago

@juergba Am I right, that passing directory along with extension as ./test/*.js* does not make any sense? So the .js** part is just ignored? And thanks for pointing to extension option. --extension ts,js is exactly what was needed.

juergba commented 4 years ago

So the *.js part is just ignored?

You are welcome. Yes, it does not make any sense/has no effect. But it's the --recursive flag which is just ignored when you run mocha --recursive "./test/*.js". The same for mocha --recursive "./test/*.ts". The extension does not make any difference (regarding the bug) in these cases.

danielyaa5 commented 3 years ago

Im still experiencing this issue