[Feature] Add global setting to make getByText default to exact: true
See original GitHub issueThe default behaviour in Testing Library is { exact: true }
, while Playwright defaults to { exact: false }
.
Naturally this is bound to catch people out. It would be useful to have at least a global setting to change the default to { exact: true }
.
See also https://github.com/microsoft/playwright/discussions/18239
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
About Queries | Testing Library
exact : Defaults to true ; matches full strings, case-sensitive. When false, matches substrings and is not case-sensitive. exact has no effect ...
Read more >getByText ignoring text in html tags · Issue #410 - GitHub
I get this error: Unable to find an element with the text: 2-3. ... you be open to adding this functionality via e.g....
Read more >How to query by text string which contains html tags using ...
All you have to do is to return true or false depending on if the node is the one you want. An example...
Read more >Making sure you're using the correct query - Tim Deschryver
Keeping your Angular Testing Library tests maintainable by using its new features.
Read more >How To Test a React App with Jest and React Testing Library
js , do that now. For Linux, use the command sudo apt install npm . For npm packages to work in this tutorial,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Related comment/issue: https://github.com/microsoft/playwright/issues/19046#issuecomment-1327913236
I do, yes. While in most cases the regex would be simple enough, there’s still more room for something to go wrong with a regex, and you have to worry about escaping etc. If in one place
/^Phone number$/
was used, and in another/^Phone number/
was used, is it intentional or a mistake? It’s hard to know.My personal preference is to limit regexes to where they are really needed, so they can get more attention and it’s obvious there’s something a bit different there.