I need to unit-test my rest api written in NodeJS. For this, I need to use supertest npm package. I was following this tutorial article for implementing the unit test functionality.
Now, in this article it is mentioned that mocha
is already included in supertest
itself, so there's no need to install it separately. So, I only install supertest
using - npm install --save-dev supertest
.
But, when I add this line in my package.json
- "test": "mocha"
, and run npm test
, it gives error saying 'mocha' is not recognized as an internal or external command
. I need to run npm install --save-dev mocha
to make it run successfully. But why do I need to include mocha
separately and if that's how it is supposed to run, why is it not mentioned in this article or on npm homepage of supertest
?