You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make exact match the default instead of partial case-insensitive match. Regex would be recommended for those cases instead.
partial: /mystring/
case-insensitive partial: /mystring/i
prefix: /^mystring/
postfix: /mystring$/
case-insensitive full string: /^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:
I could see implementing this by exposing the final options argument to the getAllByAttribute helper to the public methods that use it so that exact: true could toggled.
Same as testing-library/react-testing-library#76 which would also expose this API
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 testing-library/react-testing-library#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: