@@ -491,7 +491,9 @@ unmount()
491
491
// your component has been unmounted and now: container.innerHTML === ''
492
492
` ` `
493
493
494
- #### ` getByLabelText (text : TextMatch , options : {selector: string = ' *' }): HTMLElement `
494
+ #### ` getByLabelText (text : TextMatch , options ): HTMLElement `
495
+
496
+ > Options: ` {selector = ' *' , exact = true , collapseWhitespace = true , trim = true }`
495
497
496
498
This will search for the label that matches the given [ ` TextMatch ` ](#textmatch),
497
499
then find the element associated with that label.
@@ -529,7 +531,9 @@ const inputNode = getByLabelText('username', {selector: 'input'})
529
531
> want this behavior (for example you wish to assert that it doesn't exist),
530
532
> then use ` queryByLabelText ` instead.
531
533
532
- #### ` getByPlaceholderText (text : TextMatch ): HTMLElement `
534
+ #### ` getByPlaceholderText (text : TextMatch , options ): HTMLElement `
535
+
536
+ > Options: ` {exact = true , collapseWhitespace = true , trim = true }`
533
537
534
538
This will search for all elements with a placeholder attribute and find one that
535
539
matches the given [ ` TextMatch ` ](#textmatch).
@@ -544,7 +548,9 @@ const inputNode = getByPlaceholderText('Username')
544
548
> NOTE: a placeholder is not a good substitute for a label so you should
545
549
> generally use ` getByLabelText ` instead.
546
550
547
- #### ` getByText (text : TextMatch ): HTMLElement `
551
+ #### ` getByText (text : TextMatch , options ): HTMLElement `
552
+
553
+ > Options: ` {selector = ' *' , exact = true , collapseWhitespace = true , trim = true , ignore = ' script, style' }`
548
554
549
555
This will search for all elements that have a text node with ` textContent `
550
556
matching the given [ ` TextMatch ` ](#textmatch).
@@ -556,7 +562,9 @@ const {getByText} = render(<a href="/about">About ℹ️</a>)
556
562
const aboutAnchorNode = getByText (' about' )
557
563
` ` `
558
564
559
- #### ` getByAltText (text : TextMatch ): HTMLElement `
565
+ #### ` getByAltText (text : TextMatch , options ): HTMLElement `
566
+
567
+ > Options: ` {exact = true , collapseWhitespace = true , trim = true }`
560
568
561
569
This will return the element (normally an ` <img >` ) that has the given ` alt `
562
570
text. Note that it only supports elements which accept an ` alt ` attribute:
@@ -576,7 +584,9 @@ const {getByAltText} = render(
576
584
const incrediblesPosterImg = getByAltText (/ incredibles. * poster$ / i )
577
585
` ` `
578
586
579
- #### ` getByTestId (text : TextMatch ): HTMLElement `
587
+ #### ` getByTestId (text : TextMatch , options ): HTMLElement `
588
+
589
+ > Options: ` {exact = true , collapseWhitespace = true , trim = true }`
580
590
581
591
A shortcut to ` ` container.querySelector( ` [data - testid = " ${yourId}" ]` ) ` ` (and it
582
592
also accepts a [ ` TextMatch ` ](#textmatch)).
0 commit comments