0

I'm trying to somewhat separate my tests into unit, integration and qa_requires folders. So I though of this structure:

| /app
|  | ...
| /tests
|  | unit\
|  |  | file1.js
|  |  | file2.js
|  | integration\
|  |  | file1.js
|  |  | file2.js
|  | qa_requires\
|  |  | file1.js
|  |  | file2.js

AFAIK, there's a caching mechanism in node to handle requires as read here but, the files are in different folders and I can't tell what I'm doing wrong for node to avoid requiring all tests.

Question: Why if I test all files under /tests with a mocha call without arguments (node_modules/.bin/mocha) it finds /test/unit/file1.js and /tests/integration/file2.js and nothing more?

Alwin Kesler
  • 1,450
  • 1
  • 20
  • 41
  • Could not get your issue? Are you saying that you want to test a particular file and running all the tests together? – Surya Apr 27 '20 at 17:10
  • I'm trying to test all files under `/tests` with a `mocha` call without arguments. It resolves `/test/unit/file1.js` and `/tests/integration/file2.js` and nothing more – Alwin Kesler Apr 27 '20 at 17:15
  • 1
    You can refer here to use --recursive option after you specify folder name . https://stackoverflow.com/questions/10753288/how-to-specify-test-directory-for-mocha – Surya Apr 27 '20 at 17:52

1 Answers1

0

Well, after many tries (and writing this post) I fixed directory structure.

From                   To
| /app                 | /app
|  | ...               |  | ...
| /tests               | /tests
|  | file1.js          |  | unit\
|  | file2.js          |  |  | file1.js
|  |                   |  |  | file2.js
|  | integration\      |  | integration\
|  |  | file1.js       |  |  | file1.js
|  |  | file2.js       |  |  | file2.js
|  | qa_requires\      |  | qa_requires\
|  |  | file1.js       |  |  | file1.js
|  |  | file2.js       |  |  | file2.js

It seems files in tests root were affecting integration and qa_requires includes. @Owner's recommendation to use --recursive is required when working deep directories.

Alwin Kesler
  • 1,450
  • 1
  • 20
  • 41