Skip to content

feat: allow text matching with a regex #41

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DanielHara
Copy link

@DanielHara DanielHara commented Jan 21, 2024

@lexanth , thank you a lot for your reply to #31 (comment)

This PR aims to address the following point mentioned by #31 (comment):

Allow custom text normalisation/matching

I did so by allowing the caller of the methods to specify a regex to match against the HTML text content.

As much as I'd like to address the other points as well, this would be my first contribution to the package, so I've aimed to make this PR as simple as possible.

By the way, about the normalisation: I still didn't implement the possibility of overriding the default normaliser, described by https://testing-library.com/docs/queries/about/#normalization, which reads:

Before running any matching logic against text in the DOM, DOM Testing Library automatically normalizes that text. By default, normalization consists of trimming whitespace from the start and end of text, and collapsing multiple adjacent whitespace characters within the string into a single space.

That's because IMHO, this behaviour will already fits the vast majority of use cases. Please do let me know if you think differently, and I'll adjust this PR!

Thank you! 🚀

@DanielHara DanielHara changed the title feat: allow matching queryAllRowsByFirstCellText with a regex feat: allow text matching with a regex Jan 21, 2024
@DanielHara
Copy link
Author

@lexanth , @pagevault-michael , any feedback on merging this? ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants