Search code examples
javascriptnode.jsmocha.jsnodemon

Why I am not able to use mocha through nodemon?


I am trying to run test cases using mocha framework. I am trying to run it through nodemon, but getting an error.

I have installed nodemon already through npm install nodemon and similarly with mocha. How do I run my project through nodemon so that my test cases show the result using mocha framework?

enter image description here

enter image description here

enter image description here

In the Command Prompt, my test cases are not running for whatever I do with nodemon.


Solution

  • Lets assume you have an entry like following in your package.json - scripts": { "start:test": "mocha test/ --recursive --exit" }

    To run the mocha test using nodemon please use the following command: nodemon --exec "npm run start:test"