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

Commit 722950c

Browse files
committed
add another spec from an issue
1 parent c1ddbf4 commit 722950c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Spec | Description
128128
--- | ---
129129
[app-action-example](cypress/component/advanced/app-action-example) | App actions against components
130130
[context](cypress/component/advanced/context) | Confirms components that use React context feature work
131+
[custom-command](cypress/component/custom-command) | Wraps `mount` in a custom command for convenience
131132
[forward-ref](cypress/component/advanced/forward-ref) | Tests a component that uses a forward ref feature
132133
[hooks](cypress/component/advanced/hooks) | Tests several components that use React Hooks like `useState`, `useCallback`
133134
[lazy-loaded](cypress/component/advanced/lazy-loaded) | Confirms components that use `React.lazy` and dynamic imports work
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference types="cypress" />
2+
/// <reference types="../../lib" />
3+
import React from 'react'
4+
import { mount } from 'cypress-react-unit-test'
5+
6+
// https://github.com/bahmutov/cypress-react-unit-test/issues/184
7+
Cypress.Commands.add('myMount', () => {
8+
return mount(<div>My mount</div>)
9+
})
10+
11+
Cypress.Commands.add('myMount2', () => {
12+
const toMount = React.createElement('div', null, ['mount 2'])
13+
return mount(toMount)
14+
})
15+
16+
describe('Wrapped mount in custom command', () => {
17+
it('works', () => {
18+
cy.myMount()
19+
cy.contains('My mount')
20+
})
21+
22+
it('works using React.createElement', () => {
23+
cy.myMount2()
24+
cy.contains('mount 2')
25+
})
26+
})

cypress/component/advanced/forward-ref/forward-ref.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/// <reference types="../../lib" />
33

44
import React from 'react'
5-
import ReactDom from 'react-dom'
65
import { mount } from 'cypress-react-unit-test'
76
import Button from './forward-ref.jsx'
87

0 commit comments

Comments
 (0)