In this section, we will see how it's possible to achieve the same results with Mocha in order to make it clear that, with React, you can use any testing framework. Also, it is good to learn the main differences between Jest, which is an integrated test framework and tries to automate all operations to provide a smooth developer experience, and Mocha, which does not make any assumptions on the tools you need. With Mocha, it is up to you to install all the different packages you need to test React in the right way.
Let's create a new folder and initialize a new npm
package with:
npm init
The first thing to install is the mocha
package:
npm install --save-dev mocha
As with Jest, to be able to write ES2015 code and JSX we have to ask Babel for some help: To make it work with Mocha, we have to install the following packages:
npm install --save-dev babel-register babel-preset-es2015 babel-
preset-react
Now that Mocha and Babel have been installed...