As discussed earlier, in order to write test cases for the React code, we will be installing some testing libraries to run tests and write assertions. Let's walk through the setup for the Chai assertion library and the Mocha testing framework. We need to install the libraries with the help of npm
.
In the terminal type:
npm i -D mocha chai
Note
install
shortform: i
devDependencies
shortform: D
(the package will be installed only in a development environment)
After the Chai and Mocha libraries are installed by the previously mentioned command, they can be found under the node_modules
directory.
We need to add the Mocha and Chai entries in our package.json
file.
Package.json code
{ "name": "JSApp", "version": "1.0.0", "description": "Get random numbers", "main": "index.js", "scripts": { "test": "mocha test.js" }, "devDependencies": { "chai": "3.2.0", "mocha": "2.2.5" } }
According to https://docs.nodejitsu.com/articles/getting-started...