@@ -76,12 +76,14 @@ when a real user uses it.
7676 * [ ` getByPlaceholderText(container: HTMLElement, text: TextMatch): HTMLElement ` ] ( #getbyplaceholdertextcontainer-htmlelement-text-textmatch-htmlelement )
7777 * [ ` getByText(container: HTMLElement, text: TextMatch): HTMLElement ` ] ( #getbytextcontainer-htmlelement-text-textmatch-htmlelement )
7878 * [ ` getByAltText(container: HTMLElement, text: TextMatch): HTMLElement ` ] ( #getbyalttextcontainer-htmlelement-text-textmatch-htmlelement )
79+ * [ ` getByTestId(container: HTMLElement, text: ExactTextMatch): HTMLElement ` ] ( #getbytestidcontainer-htmlelement-text-exacttextmatch-htmlelement )
7980 * [ ` wait ` ] ( #wait )
8081 * [ ` waitForElement ` ] ( #waitforelement )
8182 * [ ` fireEvent(node: HTMLElement, event: Event) ` ] ( #fireeventnode-htmlelement-event-event )
8283* [ Custom Jest Matchers] ( #custom-jest-matchers )
8384 * [ Using other assertion libraries] ( #using-other-assertion-libraries )
8485* [ ` TextMatch ` ] ( #textmatch )
86+ * [ ExactTextMatch] ( #exacttextmatch )
8587* [ ` query ` APIs] ( #query-apis )
8688* [ ` queryAll ` and ` getAll ` APIs] ( #queryall-and-getall-apis )
8789* [ ` bindElementToQueries ` ] ( #bindelementtoqueries )
@@ -248,10 +250,10 @@ and [`<area>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/area)
248250const incrediblesPosterImg = getByAltText (container, / incredibles. * poster$ / i )
249251```
250252
251- #### ` getByTestId(container: HTMLElement, text: TextMatch ): HTMLElement `
253+ ### ` getByTestId(container: HTMLElement, text: ExactTextMatch ): HTMLElement `
252254
253255A shortcut to `` container.querySelector(`[data-testid="${yourId}"]`) `` (and it
254- also accepts a [ ` TextMatch ` ] ( #textmatch ) ).
256+ also accepts an [ ` ExactTextMatch ` ] ( #exacttextmatch ) ).
255257
256258``` javascript
257259// <input data-testid="username-input" />
@@ -477,6 +479,25 @@ getByText(container, (content, element) => {
477479})
478480` ` `
479481
482+ ### ExactTextMatch
483+
484+ Some APIs use ExactTextMatch , which is the same as TextMatch but case -sensitive
485+ and does not match substrings ; however , regexes and functions are also accepted
486+ for custom matching .
487+
488+ ` ` ` js
489+ // <button data-testid="submit-button">Go</button>
490+
491+ // all of the following will find the button
492+ getByTestId(container, 'submit-button') // exact match
493+ getByTestId(container, /submit*/) // regex match
494+ getByTestId(container, content => content.startsWith('submit')) // function
495+
496+ // all of the following will NOT find the button
497+ getByTestId(container, 'submit-') // no substrings
498+ getByTestId(container, 'Submit-Button') // case-sensitive
499+ ` ` `
500+
480501## ` query ` APIs
481502
482503Each of the ` get ` APIs listed in [the ' Usage' ](#usage ) section above have a
0 commit comments