question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Add global setting to make getByText default to exact: true

See original GitHub issue

The 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:open
  • Created 10 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Nav-2dcommented, Dec 2, 2022
0reactions
jpveooyscommented, Dec 7, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found