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

Commit a6eb6d8

Browse files
committed
add note about testing library
1 parent 95caa6a commit a6eb6d8

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- What is this? This package allows you to use [Cypress](https://www.cypress.io/) test runner to unit test your React components with zero effort.
88

99
- How is this different from [Enzyme](https://github.com/airbnb/enzyme) or [RTL](https://testing-library.com/docs/react-testing-library/intro)? It is similar in functionality BUT runs the component in the real browser with full power of Cypress E2E test runner: [live GUI, full API, screen recording, CI support, cross-platform](https://www.cypress.io/features/). Ohh, and the code coverage is built-in!
10+
- If you like using `@testing-library/react`, you can use `@testing-library/cypress` for the same `findBy`, `queryBy` commands, see one of the examples in the list below
1011

1112
## Known problems
1213

@@ -97,7 +98,7 @@ Spec | Description
9798
[react-router-v6](cypress/component/advanced/react-router-v6) | Example testing a [React Router v6](https://github.com/ReactTraining/react-router/blob/dev/docs/guides/getting-started.md)
9899
[renderless](cypress/component/advanced/renderless) | Testing a component that does not need to render itself into the DOM
99100
[set-timeout-example](cypress/component/advanced/set-timeout-example) | Control the clock with `cy.tick` and test loading components that use `setTimeout`
100-
[testing-lib-example](cypress/component/advanced/testing-lib-example) | A spec adopted from [RTL intro](https://testing-library.com/docs/react-testing-library/example-intro)
101+
[testing-lib-example](cypress/component/advanced/testing-lib-example) | A spec adopted from [@testing-library/react](https://testing-library.com/docs/react-testing-library/example-intro) that uses [@testing-library/cypress](https://testing-library.com/docs/cypress-testing-library/intro)
101102
[timers](cypress/component/advanced/timers) | Testing components that set timers, adopted from [ReactJS Testing recipes](https://reactjs.org/docs/testing-recipes.html#timers)
102103
[tutorial](cypress/component/advanced/tutorial) | A few tests adopted from [ReactJS Tutorial](https://reactjs.org/tutorial/tutorial.html)
103104
<!-- prettier-ignore-end -->

cypress/component/advanced/testing-lib-example/testing-lib-spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ it('loads and displays greeting (testing-lib)', () => {
99
const url = '/greeting'
1010
mount(<Fetch url={url} />)
1111

12-
cy.queryByText('Load Greeting').click()
12+
cy.queryByText('Load Greeting')
13+
.wait(1000)
14+
.click()
1315
cy.queryByRole('heading').should('have.text', 'Hello there')
1416
cy.queryByRole('button').should('be.disabled')
1517
cy.get('@greet')

cypress/support/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
// using "npm run transpile"
1818
import 'cypress-react-unit-test/hooks'
1919
// import '@percy/cypress'
20+
21+
// https://testing-library.com/docs/cypress-testing-library/intro
2022
import '@testing-library/cypress/add-commands'
2123
// import 'cypress-plugin-snapshots/commands'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@material-ui/icons": "4.5.1",
5757
"@material-ui/lab": "4.0.0-alpha.39",
5858
"@percy/cypress": "1.0.9",
59-
"@testing-library/cypress": "5.0.2",
59+
"@testing-library/cypress": "6.0.0",
6060
"@types/node": "9.6.49",
6161
"@types/react": "16.9.16",
6262
"@types/react-dom": "16.9.4",

0 commit comments

Comments
 (0)