-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
BREAKING CHANGEThis change will require a major version bumpThis change will require a major version bumpenhancementNew feature or requestNew feature or request
Description
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.
- 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:
- 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 that exact: 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
Metadata
Metadata
Assignees
Labels
BREAKING CHANGEThis change will require a major version bumpThis change will require a major version bumpenhancementNew feature or requestNew feature or request