Skip to content

Commit 169434f

Browse files
NoriSteKent C. Dodds
authored and
Kent C. Dodds
committed
docs: update README.md (#221)
I've aligned the documented signature of some functions in the README I made that because I got confused at the beginning and I took some time to understand that they were just some examples (and not a real documentation). - [x] Documentation - [x] Ready to be merged
1 parent 8605224 commit 169434f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ unmount()
491491
// your component has been unmounted and now: container.innerHTML === ''
492492
```
493493
494-
#### `getByLabelText(text: TextMatch, options: {selector: string = '*'}): HTMLElement`
494+
#### `getByLabelText(text: TextMatch, options): HTMLElement`
495+
496+
> Options: `{selector = '*', exact = true, collapseWhitespace = true, trim = true}`
495497
496498
This will search for the label that matches the given [`TextMatch`](#textmatch),
497499
then find the element associated with that label.
@@ -529,7 +531,9 @@ const inputNode = getByLabelText('username', {selector: 'input'})
529531
> want this behavior (for example you wish to assert that it doesn't exist),
530532
> then use `queryByLabelText` instead.
531533
532-
#### `getByPlaceholderText(text: TextMatch): HTMLElement`
534+
#### `getByPlaceholderText(text: TextMatch, options): HTMLElement`
535+
536+
> Options: `{exact = true, collapseWhitespace = true, trim = true}`
533537
534538
This will search for all elements with a placeholder attribute and find one that
535539
matches the given [`TextMatch`](#textmatch).
@@ -544,7 +548,9 @@ const inputNode = getByPlaceholderText('Username')
544548
> NOTE: a placeholder is not a good substitute for a label so you should
545549
> generally use `getByLabelText` instead.
546550
547-
#### `getByText(text: TextMatch): HTMLElement`
551+
#### `getByText(text: TextMatch, options): HTMLElement`
552+
553+
> Options: `{selector = '*', exact = true, collapseWhitespace = true, trim = true, ignore = 'script, style'}`
548554
549555
This will search for all elements that have a text node with `textContent`
550556
matching the given [`TextMatch`](#textmatch).
@@ -556,7 +562,9 @@ const {getByText} = render(<a href="/about">About ℹ️</a>)
556562
const aboutAnchorNode = getByText('about')
557563
```
558564
559-
#### `getByAltText(text: TextMatch): HTMLElement`
565+
#### `getByAltText(text: TextMatch, options): HTMLElement`
566+
567+
> Options: `{exact = true, collapseWhitespace = true, trim = true}`
560568
561569
This will return the element (normally an `<img>`) that has the given `alt`
562570
text. Note that it only supports elements which accept an `alt` attribute:
@@ -576,7 +584,9 @@ const {getByAltText} = render(
576584
const incrediblesPosterImg = getByAltText(/incredibles.*poster$/i)
577585
```
578586
579-
#### `getByTestId(text: TextMatch): HTMLElement`
587+
#### `getByTestId(text: TextMatch, options): HTMLElement`
588+
589+
> Options: `{exact = true, collapseWhitespace = true, trim = true}`
580590
581591
A shortcut to `` container.querySelector(`[data-testid="${yourId}"]`) `` (and it
582592
also accepts a [`TextMatch`](#textmatch)).

0 commit comments

Comments
 (0)