Test Overview
This test mounts a simple React component using Cypress. It verifies that the component renders correctly and displays the expected text.
This test mounts a simple React component using Cypress. It verifies that the component renders correctly and displays the expected text.
import React from 'react' import { mount } from 'cypress/react' function Greeting() { return <h1>Hello, Cypress!</h1> } describe('Mount React Component', () => { it('renders the Greeting component', () => { mount(<Greeting />) cy.get('h1').should('contain.text', 'Hello, Cypress!') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner is ready | - | PASS |
| 2 | Mounts the Greeting React component using mount() | Browser displays the Greeting component with <h1>Hello, Cypress!</h1> | - | PASS |
| 3 | Finds the <h1> element using cy.get('h1') | The <h1> element is present in the DOM | - | PASS |
| 4 | Checks that the <h1> contains text 'Hello, Cypress!' using .should('contain.text') | The <h1> text matches 'Hello, Cypress!' | Verify <h1> text content equals 'Hello, Cypress!' | PASS |