I use mocha --recursive --timeout 15000
CLI command to run all test placed in /test
local folder. How can I target specific folder ?

- 3,386
- 4
- 21
- 35
-
1Possible duplicate of [How to specify test directory for mocha?](http://stackoverflow.com/questions/10753288/how-to-specify-test-directory-for-mocha) – Yury Tarabanko May 02 '16 at 17:36
2 Answers
You can just run:
mocha path-to-dir/**/*.js --timeout 15000
The two ** are the same as --recursive

- 5,833
- 4
- 42
- 67
There are quite a few options here depending on exactly what you need, imho straight execution based on path gets a bit cumbersome.
Directory based segregation of tests
Everything in a directory - mocha test/<folderPath>/*.js
Everything including sub-directories - mocha test/<folderPath>/**/*.js
Pattern matching for suites ( or tests )
Suite - mocha --grep <suiteName>
Pattern Match - mocha --grep <pattern>
Negative Pattern matching for suites ( or tests )
Suite - mocha --grep <suiteName> --invert
Pattern Match - mocha --grep <pattern> --invert
Tagging
You can also execute test based on tags
within the it() portion of the test.
Tagging uses the --grep feature which also allows for negative tag matching.
More can be found here - https://github.com/mochajs/mocha/wiki/Tagging

- 280
- 2
- 7