-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Breaking change proposal: Use exact string match by default #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm in favor of this change and I see no reason to go forward with a PR and push a major version bump. This probably should have been filed in |
I'll add a link over there, too |
Merged in https://github.com/kentcdodds/dom-testing-library/releases/tag/v2.0.0
|
Whoops, I probably shouldn't have just pushed an update to the version. I was being lazy. I'm pushing up a fix to the tests right now. We'll need an update to the types and examples. My bad :-/ Sorry about the laziness on my part. |
I was thinking that the types for dom-testing-library should probably exist in that repo and then be imported from there. I can write the types there if you like? |
That sounds great @maddijoyce, thanks! |
@maddijoyce sending a PR right now with what I think they are, you can finalize it. |
It's possible you'll want to remove a bunch of README stuff and point it to dom-testing-library instead |
🎉 This issue has been resolved in version 3.0.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Describe the feature you'd like:
Make exact match the default instead of partial case-insensitive match. Regex would be recommended for those cases instead.
/mystring/
/mystring/i
/^mystring/
/mystring$/
/^mystring$/i
One thing that would more involved to replicate with inline regexes is that the current implementation trims the string and replaces symbols with spaces:
- const normalizedText = textToMatch.trim().replace(/\s+/g, ' ')
See #74 (comment)
Suggested implementation:
I could see implementing this by exposing the final options argument to the
getAllByAttribute
helper to the public methods that use it so thatexact: true
could toggled.https://github.com/kentcdodds/dom-testing-library/blob/master/src/queries.js#L73
Describe alternatives you've considered:
Leave the matcher alone
Teachability, Documentation, Adoption, Migration Strategy:
Show common regex patterns like the ones above^ in the docs.
Is this a breaking change?
Yes
The text was updated successfully, but these errors were encountered: