Skip to content

Latest commit

 

History

History
 
 

unit-testing__react

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Unit testing React code

A little React greeting.jsx component is tested (inside Cypress test runner) using:

cypress-react-unit-test example

⚠️ This is an experimental feature that uses "experimentalComponentTesting": true flag in cypress.json and requires Cypress v4.5.0+. See on.cypress.io/experimental for more details.

The screenshot below shows how cypress-react-unit-test mounts a React component as "mini" web application.

Testing React component using cypress-react-unit-test

Name Description
cypress-react-unit-test-spec.js Simple button click
counter-spec.js Testing a counter component that uses React hook

Read Sliding Down the Testing Pyramid for more details about testing individual components by mounting them in the Cypress test runner's iframe.