Skip to content

Update README.md #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,9 @@ unmount()
// your component has been unmounted and now: container.innerHTML === ''
```

#### `getByLabelText(text: TextMatch, options: {selector: string = '*'}): HTMLElement`
#### `getByLabelText(text: TextMatch, options): HTMLElement`

> Options: `{selector = '*', exact = true, collapseWhitespace = true, trim = true}`

This will search for the label that matches the given [`TextMatch`](#textmatch),
then find the element associated with that label.
Expand Down Expand Up @@ -529,7 +531,9 @@ const inputNode = getByLabelText('username', {selector: 'input'})
> want this behavior (for example you wish to assert that it doesn't exist),
> then use `queryByLabelText` instead.

#### `getByPlaceholderText(text: TextMatch): HTMLElement`
#### `getByPlaceholderText(text: TextMatch, options): HTMLElement`

> Options: `{exact = true, collapseWhitespace = true, trim = true}`

This will search for all elements with a placeholder attribute and find one that
matches the given [`TextMatch`](#textmatch).
Expand All @@ -544,7 +548,9 @@ const inputNode = getByPlaceholderText('Username')
> NOTE: a placeholder is not a good substitute for a label so you should
> generally use `getByLabelText` instead.

#### `getByText(text: TextMatch): HTMLElement`
#### `getByText(text: TextMatch, options): HTMLElement`

> Options: `{selector = '*', exact = true, collapseWhitespace = true, trim = true, ignore = 'script, style'}`

This will search for all elements that have a text node with `textContent`
matching the given [`TextMatch`](#textmatch).
Expand All @@ -556,7 +562,9 @@ const {getByText} = render(<a href="/about">About ℹ️</a>)
const aboutAnchorNode = getByText('about')
```

#### `getByAltText(text: TextMatch): HTMLElement`
#### `getByAltText(text: TextMatch, options): HTMLElement`

> Options: `{exact = true, collapseWhitespace = true, trim = true}`

This will return the element (normally an `<img>`) that has the given `alt`
text. Note that it only supports elements which accept an `alt` attribute:
Expand All @@ -576,7 +584,9 @@ const {getByAltText} = render(
const incrediblesPosterImg = getByAltText(/incredibles.*poster$/i)
```

#### `getByTestId(text: TextMatch): HTMLElement`
#### `getByTestId(text: TextMatch, options): HTMLElement`

> Options: `{exact = true, collapseWhitespace = true, trim = true}`

A shortcut to `` container.querySelector(`[data-testid="${yourId}"]`) `` (and it
also accepts a [`TextMatch`](#textmatch)).
Expand Down