sazr
sazr

Reputation: 25938

Tell Mocha where to look for test files

How can I tell Mocha where to look for my test files? My test files dont reside in the standard project root ./test folder. My test sit in Modules/.*/Tests/.

I've attempted to use the --grep command line argument but I have a feeling this argument looks for test NAMES not for test FILE NAMES.

mocha --grep Modules\/.*\/Tests

The above command gives the error:

Warning: Could not find any test files matching pattern: test
No test files found

Upvotes: 10

Views: 13070

Answers (1)

Abdennour TOUMI
Abdennour TOUMI

Reputation: 93491

You have to match not only directory but also its files . Besides, do no need grep , use only -- :

mocha -- Modules/**/Tests/*.js
// or `mocha -- Modules/Tests/*.js` (I am not sure because you didn't give the project hierarchy )

Upvotes: 19

Related Questions