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.

3
  • "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 Commented Dec 18, 2020 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 Commented Dec 18, 2020 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. Commented Dec 18, 2020 at 16:13

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.