Skip to content

Commit 4c01fba

Browse files
authored
Update cy examples to use find* (#462)
1 parent f509f5e commit 4c01fba

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/dom-testing-library/api-queries.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ const inputNode = screen.getByPlaceholderText('Username')
245245
<!--Cypress-->
246246

247247
```js
248-
cy.getByPlaceholderText('Username').should('exist')
248+
cy.findByPlaceholderText('Username').should('exist')
249249
```
250250

251251
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -301,7 +301,7 @@ const aboutAnchorNode = screen.getByText(/about/i)
301301
<!--Cypress-->
302302

303303
```js
304-
cy.getByText(/about/i).should('exist')
304+
cy.findByText(/about/i).should('exist')
305305
```
306306

307307
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -376,7 +376,7 @@ const incrediblesPosterImg = screen.getByAltText(/incredibles.*? poster/i)
376376
<!--Cypress-->
377377

378378
```js
379-
cy.getByAltText(/incredibles.*? poster/i).should('exist')
379+
cy.findByAltText(/incredibles.*? poster/i).should('exist')
380380
```
381381

382382
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -432,8 +432,8 @@ const closeElement = screen.getByTitle('Close')
432432
<!--Cypress-->
433433

434434
```js
435-
cy.getByTitle('Delete').should('exist')
436-
cy.getByTitle('Close').should('exist')
435+
cy.findByTitle('Delete').should('exist')
436+
cy.findByTitle('Close').should('exist')
437437
```
438438

439439
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -488,7 +488,7 @@ const lastNameInput = screen.getByDisplayValue('Norris')
488488
<!--Cypress-->
489489

490490
```js
491-
cy.getByDisplayValue('Norris').should('exist')
491+
cy.findByDisplayValue('Norris').should('exist')
492492
```
493493

494494
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -525,7 +525,7 @@ const messageTextArea = screen.getByDisplayValue('Hello World')
525525
<!--Cypress-->
526526

527527
```js
528-
cy.getByDisplayValue('Hello World').should('exist')
528+
cy.findByDisplayValue('Hello World').should('exist')
529529
```
530530

531531
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -566,7 +566,7 @@ const selectElement = screen.getByDisplayValue('Alaska')
566566
<!--Cypress-->
567567

568568
```js
569-
cy.getByDisplayValue('Alaska').should('exist')
569+
cy.findByDisplayValue('Alaska').should('exist')
570570
```
571571

572572
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -641,7 +641,7 @@ assertions about the `Open dialog`-button you would need to use
641641
The default value for `hidden` can [be configured](api-configuration#configuration).
642642

643643
Certain roles can have a selected state. You can filter the
644-
returned elements that by their selected state
644+
returned elements by their selected state
645645
by setting `selected: true` or `selected: false`.
646646

647647
For example in
@@ -686,7 +686,7 @@ const dialogContainer = screen.getByRole('dialog')
686686
<!--Cypress-->
687687

688688
```js
689-
cy.getByRole('dialog').should('exist')
689+
cy.findByRole('dialog').should('exist')
690690
```
691691

692692
<!--END_DOCUSAURUS_CODE_TABS-->
@@ -735,7 +735,7 @@ const element = screen.getByTestId('custom-element')
735735
<!--Cypress-->
736736

737737
```js
738-
cy.getByTestId('custom-element').should('exist')
738+
cy.findByTestId('custom-element').should('exist')
739739
```
740740

741741
<!--END_DOCUSAURUS_CODE_TABS-->

0 commit comments

Comments
 (0)