Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

cypress-io/cypress-react-unit-test

Repository files navigation

cypress-react-unit-test Build Status

Unit test React components using Cypress

Use

// import the component you want to test import { HelloState } from '../../src/hello-x.jsx' import React from 'react' import { mount } from 'cypress-react-unit-test' describe('HelloState component', () => { it('works', () => { // mount the component under test mount(<HelloState />) // start testing! cy.contains('Hello Spider-man!').then(() => { // mounted component is at Cypress.component Cypress.component.setState({ name: 'React' }) }) cy.contains('Hello React!') }) })

Examples