Code Monkey home page Code Monkey logo

react-jest-cypress-coverage's Introduction

Testing Demo App - This project is clone of https://github.com/bahmutov/testing-react.git

Goal is to publish jest + cypress combined code coverage in sonar

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:

Library Description
Jest Automated testing
Enzyme Unit test React components in isolation via shallow or with children via mount
enzyme-adapter-react-16 Configures enzyme to work with React 16
react-test-renderer Render React components to JSON for snapshot testing
redux-mock-store Mock store for testing your redux async action creators and middleware
Cypress In 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

Docker commands

Using cypress/included:6.2.1 docker image

command to check cypress and browser info

docker run -it -v <absolutePath>/testing-react:/e2e -w /e2e --entrypoint=cypress cypress/included:6.2.1 info

command to execute cypress e2e with chrome browser

docker run -it -v C:/Users/nkumarpa/workspace/testing-react:/e2e -w /e2e cypress/included:6.2.1 --browser chrome

react-jest-cypress-coverage's People

Contributors

allah-the-dev avatar bahmutov avatar coryhouse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.