expect-puppeteer: change toMatch
text
matcher to check if argument is regex or not to match
#50
Labels
good first issue 🤙
Good for newcomers
First and foremost, I just want to express gratitude for maintaining this project! It's a crucial resource for doing anything with jest and puppeteer.
One pain point though is from usage of
text
matching option on some of the matchers (e.g.,toMatch
ortoMatchElement
). It's confusing (especially for newcomers) that the string you pass to it is actually used as a regex. I realized that it's documented this way, but it would be a lot nicer if the library could do atypeof
to check if the argument is astring
orobject
(regex's actual type from what I can tell). Then, it just does a simpleincludes
or an actualmatch
on thetextContent
respectively. I've run into weird cases where I'm trying to match on money values (e.g.,'$1000'
) and i've found myself beating my head on more than one occasion trying to figure out why text won't match (the$
is not escaped, obviously). Also, sometimes all you really need is a simplestring
match without needing to remember to escape everything in the regex for what you're matching.I know that this would bring about a breaking change, so it might not be something you'd be thrilled to add right now. However, I think it could definitely help for readability and usability of this library.
The text was updated successfully, but these errors were encountered: