Skip to content

Commit 26399e4

Browse files
HTMLheadKent C. Dodds
authored and
Kent C. Dodds
committed
docs: fix cypress-testing-library example link and example (#270)
1 parent 96b436f commit 26399e4

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

docs/cypress-testing-library/intro.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,25 @@ and `queryAllBy` commands.
4343

4444
You can find [all library definitions here](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__cypress/index.d.ts).
4545

46-
To show some simple examples (from
47-
[https://github.com/testing-library/cypress-testing-library/blob/master/cypress/integration/commands.spec.js](https://github.com/testing-library/cypress-testing-library/blob/master/cypress/integration/commands.spec.js)):
46+
To show some simple examples (from [https://github.com/testing-library/cypress-testing-library/tree/master/cypress/integration](https://github.com/testing-library/cypress-testing-library/tree/master/cypress/integration)):
4847

4948
```javascript
50-
cy.getAllByText('Jackie Chan').click()
51-
cy.queryByText('Button Text').should('exist')
52-
cy.queryByText('Non-existing Button Text').should('not.exist')
53-
cy.queryByLabelText('Label text', { timeout: 7000 }).should('exist')
54-
cy.get('form').within(() => {
55-
cy.getByText('Button Text').should('exist')
49+
cy.findAllByText(/^Button Text \d$/)
50+
.should('have.length', 2)
51+
.click({ multiple: true })
52+
.should('contain', 'Button Clicked')
53+
cy.queryByText('Button Text 1')
54+
.click()
55+
.should('contain', 'Button Clicked')
56+
cy.queryByText('Non-existing Button Text', { timeout: 100 }).should('not.exist')
57+
cy.queryByLabelText('Label 1')
58+
.click()
59+
.type('Hello Input Labelled By Id')
60+
cy.get('#nested').within(() => {
61+
cy.queryByText('Button Text 2').click()
5662
})
57-
cy.get('form').then(subject => {
58-
cy.getByText('Button Text', { container: subject }).should('exist')
63+
cy.get('#nested').then(subject => {
64+
cy.queryByText(/^Button Text/, { container: subject }).click()
5965
})
6066
```
6167

0 commit comments

Comments
 (0)