February 2019
Beginner
694 pages
18h 4m
English
React suggests using Jest as its default test runner. All of our previous samples have been using Karma as a test runner, but the integration between React and Jest means that it is very simple to set up, and we can get our tests up and running very quickly. We will use Jest for our React tests in this section. To install Jest, simply type the following:
npm install jest -save-dev
Along with Jest, we will need Jasmine and its types as follows:
npm install jasmine @types/jasmine --save-dev
Once installed, we need to make a small change to our package.json file in order to fire up Jest and run our tests, as follows:
{ "name": "react-sample", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "jest" }, ...Read now
Unlock full access