-
Notifications
You must be signed in to change notification settings - Fork 471
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
feat(getByText): add ignore option which defaults to 'script'
#109
Conversation
Codecov Report
@@ Coverage Diff @@
## master #109 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 9 9
Lines 184 185 +1
Branches 50 51 +1
=====================================
+ Hits 184 185 +1
Continue to review full report at Codecov.
|
More explanation here: https://www.youtube.com/watch?v=LYB0SEYaBlE |
exact = true, | ||
collapseWhitespace = true, | ||
trim = true, | ||
ignore = 'script', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think script and style would be a better default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'll add that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm just a couple minutes late...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. I just pushed an update directly to master. I figured the overhead would be unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
🎉 This PR is included in version 3.7.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What: add
ignore
option to*ByText
which defaults to'script'
Why:
In our app at PayPal we're testing with Cypress and our localization content is set in a script tag on the page when it's rendered by the server. When using
getByText
withcypress-testing-library
, we were getting that script tag before the app had a chance to render.I'm pretty confident that 99.999% of the time people wont want to get a script tag with
getByText
, so the default makes sense to me.How:
Added another layer of filtering to
queryAllByText
to filter nodes which return true for.matches(ignore)
. Feel pretty flexible. Happy that DOM API exists!Checklist: