Skip to content

Commit

Permalink
Update documentation for ByLabelText queries
Browse files Browse the repository at this point in the history
  • Loading branch information
airjp73 authored Oct 6, 2019
1 parent f0e68a6 commit 915a1cb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions docs/dom-testing-library/api-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,20 @@ cy.getByLabelText('username').should('exist')

<!--END_DOCUSAURUS_CODE_TABS-->

It will NOT find the input node for label text broken up by elements. For this
case, you can provide a `selector` in the options:
You may also need to filter down the results of the query.
For that you can use the `selector` option:

```html
<label> <span>Username</span> <input /> </label>
```js
// Label containing multiple elements
<label>
<span>Username</span>
<input />
</label>

// Multiple elements labelled via aria-labelledby
<label id="username">Username</label>
<input aria-labelledby="username" />
<span aria-labelledby="username">Please enter your username</span>
```

```js
Expand Down

0 comments on commit 915a1cb

Please sign in to comment.