Machtyn
Machtyn

Reputation: 3272

mocha is not finding my path when using mocha.opts

I found a great answer on how to get mocha to recognize that my tests files are located in another path and to recursively traverse that path - create mocha.opts in the ./test folder. However, I'm having some issue with the file. Here's what I have in my mocha.opts file:

services/endpoints
--recursive

The test files themselves (200Tests.js, 400Tests.js, etc) live in various paths:

./test/services/endpoints/
                    |---users
                    |---persons
                    |---|---findByName
                    |---|---|---200Tests.js
                    |---|---|---400Tests.js
                    |---|---findById
                    |---|---|---200Tests.js
                    |---|---|---400Tests.js

etc.

From my project root, I issue mocha from the terminal and get: Error: cannot resolve path (or pattern) 'services/endpoints'. Am I doing something wrong or missing something?

Upvotes: 0

Views: 523

Answers (1)

Louis
Louis

Reputation: 151411

Use test/services/endpoints in your mocha.opts file.

The directory from which Mocha interprets paths is the directory from which the mocha executable is launched, which is normally the top level of your project rather than the test subdirectory.

Upvotes: 2

Related Questions