To install and run Mocha, the Node.js testing module, we install the mocha
package globally.
To install it, we run
npm install --global mocha
to install mocha
globally.
We can also install it in the project folder as a dev dependency with
npm install --save-dev mocha
Then in package.json, we add
{
//...
"scripts": {
"test": "mocha"
}
//...
}
to add the test
script to run mocha
installed in the node_modules folder.