By default, mocha looks for files in the
tree . 0 directories, 0 files
mocha Error: cannot resolve path (or pattern) 'test'
If you have files in subdirectories of
test, you’ll need to pass the recursive flag:
What if you want to specify tests in a different directory?
You can pass the directory as a CLI argument:
Now what if you want to match files like
Easy! Use a glob expression:
And if you need to recurse through all nested directories:
But what if you want to match all files in
test except for
You’ll need to negate the filename in the pattern:
Finally, if you need to ignore
node_modules and match files like
qux.spec.js in the project root:
For more information on globs, check out glob-primer.