How to do it...

After we've installed Jest, we need to configure it:

  1. Add the tests scripts and the Jest configuration into our package.json:
  {    "name": "react-pro",    "version": "1.0.0",    "scripts": {      "clean": "rm -rf dist/ && rm -rf public/app",      "start": "npm run clean & NODE_ENV=development       BABEL_ENV=development nodemon src/server --watch src/server --      watch src/shared --exec babel-node --presets es2015",      "start-analyzer": "npm run clean && NODE_ENV=development       BABEL_ENV=development ANALYZER=true babel-node src/server",      "test": "node scripts/test.js src --env=jsdom",      "coverage": "node scripts/test.js src --coverage --env=jsdom"    },    "jest": {      "setupTestFrameworkScriptFile": "      <rootDir>/config/jest/setupTestFramework.js",      "collectCoverageFrom ...

Get React Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.