How to specify test directory for mocha?

Freewind picture Freewind · May 25, 2012 · Viewed 170.5k times · Source

Mocha tries to find test files under test by default, how do I specify another dir, e.g. server-test?

Answer

Behrang picture Behrang · Nov 11, 2013

Use this:

mocha server-test

Or if you have subdirectories use this:

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

Note the use of double quotes. If you omit them you may not be able to run tests in subdirectories.