In my npm package, I would like to emulate the pattern Meteor follows: a source file (named client.js
) has a test file (named client.tests.js
) live in a src/
folder. Tests run with the npm test
command.
I'm following the usage docs to the 't'. I do not want to use a find
in my package test command.
I understand that mocha can recursively execute tests:
mocha --recursive
I understand that mocha can execute tests in a specific subfolder using the --recursive
flag:
mocha src --recursive
I also understand that I can specify a glob to filter files by passing *.tests.js
:
mocha *.tests.js
But, I want all three. I want mocha to test only files ending in tests.js
in the src folder, recursively checking subdirectories.
mocha --recursive *.tests.js
// See the files?
$ > ll ./src/app/
total 168
-rw-r--r-- ... client.js
-rw-r--r-- ... client.tests.js
// Option A
$ > mocha --recursive *.tests.js
Warning: Could not find any test files matching pattern: *.tests.js
No test files found
// Option B
$ > mocha *.tests.js --recursive
Warning: Could not find any test files matching pattern: *.tests.js
No test files found.
// Option C
$ > mocha --recursive src/app/*.tests.js
3 passing (130ms)
3 failing
So...
- Why is mocha not picking up the
*.tests.js
files in the subfolders?
- Why DOES it work if I specify the full path to the file?
- How do I make it work as desired?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…