Home

Awesome

Testing Demo App

This project was bootstrapped with Create React App v3.

Fuel savings

Quick Start

npm install
npm start

The above commands will install dependencies and start the app. To run tests, run npm test on a separate command line. There are no tests written in the master branch.

Tip: to start the application and the mock API and open Cypress, you can use start-server-and-test utility.

npm run dev

Testing libraries

This instance of create-react-app has been enhanced with the following testing libraries:

LibraryDescription
JestAutomated testing
EnzymeUnit test React components in isolation via shallow or with children via mount
enzyme-adapter-react-16Configures enzyme to work with React 16
react-test-rendererRender React components to JSON for snapshot testing
redux-mock-storeMock store for testing your redux async action creators and middleware
CypressIn browser integration testing via Mocha and Chai

Complete code coverage with Cypress

When you run the application with npm start it instruments the source code using @cypress/instrument-cra module. The code coverage is collected using @cypress/code-coverage plugin and saved in coverage folder.

Coverage report

Installation

Important: your application should have been created using CRA v3 and include react-scripts v2+.

First, add NPM module @cypress/instrument-cra as a dev dependency

npm install --save-dev @cypress/instrument-cra

Load this module when starting the application in package.json

{
  "scripts": {
    "start": "react-scripts -r @cypress/instrument-cra start"
  }
}

Your application's source code should be instrumented when you run npm start. Then you can use @cypress/code-coverage plugin to run Cypress tests and save code coverage reports.

See more

For more details about code coverage, see