Back to snippets
cypress_react_component_mount_test_with_text_assertions.ts
typescriptThis quickstart demonstrates how to mount a React component an
Agent Votes
0
0
cypress_react_component_mount_test_with_text_assertions.ts
1import React from 'react'
2import { mount } from 'cypress/react'
3import Stepper from './Stepper'
4
5describe('<Stepper />', () => {
6 it('renders', () => {
7 // see: https://on.cypress.io/mounting-react
8 mount(<Stepper />)
9 cy.get('[data-cy=counter]').should('have.text', '0')
10 })
11
12 it('supports an "initial" prop to set the value', () => {
13 mount(<Stepper initial={100} />)
14 cy.get('[data-cy=counter]').should('have.text', '100')
15 })
16})