0

I am working on a Node.js backend application that uses mocha to run unit and integration tests.
As seen here and there (and many other that I do not post here but all say the same) I have the following test script:

"scripts": {
    "pretest": "eslint .",
    "test": "mocha --recursive \"tests/**/*.js\""
}

Tests are arranged as follow :

tests
  |_integration
  |   |_endpoint1
  |   |    |_test-endpoint.js
  |_unit
  |   |_components
  |   |    |_test_component1.js
  |   |    |_....
  |   |_services
  |   |    |_test-service1.js
  |   |    |_test-service2.js
  |   |    |_....
  |.....

When I run the npm test command mocha runs only test-service2.js and stops.

I am currently working on Mac with zsh as shell.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Jib'z
  • 953
  • 1
  • 12
  • 23
  • `"test": "mocha --require test-setup.js './**/*.spec.js'"` such approach seems more reasonable for me. Test files should not have a different file type such as `.spec.js` – canbax Dec 18 '20 at 12:08
  • 1
    its hard to say without seeing the contents of the test-service1.js. Might be the case the runner is not able to detect any test-suite or test cases in that file and hence it runs just one file – Brijesh Prasad Dec 18 '20 at 13:11
  • Thx for your hint @BrijeshPrasad I removed the test-service1.js file and all other tests seems to run. What bother me is that the tests written in the test-service1.js file are run and successfull. I'll check for other problems. – Jib'z Dec 18 '20 at 16:13

0 Answers0