@@ -679,13 +679,17 @@ getByText(node, 'text', {
679
679
680
680
### TextMatch Examples
681
681
682
- ``` javascript
683
- // <div>
684
- // Hello World
685
- // </div>
682
+ Given the following HTML:
686
683
687
- // WILL find the div:
684
+ ``` html
685
+ <div >
686
+ Hello World
687
+ </div >
688
+ ```
688
689
690
+ ** _ Will_ find the div:**
691
+
692
+ ``` javascript
689
693
// Matching a string:
690
694
getByText (container, ' Hello World' ) // full string match
691
695
getByText (container, ' llo Worl' , { exact: false }) // substring match
@@ -699,11 +703,17 @@ getByText(container, /Hello W?oRlD/i) // advanced regex
699
703
700
704
// Matching with a custom function:
701
705
getByText (container, (content , element ) => content .startsWith (' Hello' ))
706
+ ```
707
+
708
+ ** _ Will not_ find the div:**
709
+
710
+ ``` javascript
711
+ // full string does not match
712
+ getByText (container, ' Goodbye World' )
702
713
703
- // WILL NOT find the div:
714
+ // case-sensitive regex with different case
715
+ getByText (container, / hello world/ )
704
716
705
- getByText (container, ' Goodbye World' ) // full string does not match
706
- getByText (container, / hello world/ ) // case-sensitive regex with different case
707
717
// function looking for a span when it's actually a div:
708
718
getByText (container, (content , element ) => {
709
719
return element .tagName .toLowerCase () === ' span' && content .startsWith (' Hello' )
0 commit comments