-
Notifications
You must be signed in to change notification settings - Fork 470
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
Add queryAll/getAll methods #28
Add queryAll/getAll methods #28
Conversation
Adds "all" methods for: - byAltText - byTestId
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'm thinking that it would be good to actually have an *All*
version for every query/get method for consistency.
And I'm thinking that we could probably have the *All*
methods be the base and the existing methods just use those and return the first element to simplify the implementation.
What do you think?
Also, we'll want to make sure to document the existence of the *All*
methods.
Yep, just wanted to start with a few cases for review.
Yeah. Would the
Yep. Also, CI failed. Should I go for 100% branch coverage? |
Yes, let's do this with no breaking changes. Yes, please maintain 100% code coverage 👍 |
OK, 🍏
|
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 didn't have time to review everything, but I think we want the getAll* APIs to throw an error if there are no matching elements.
✅ Changed |
src/queries.js
Outdated
container, | ||
)}`, | ||
) | ||
throw noMatchingAltText(container, alt) |
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.
What if instead of creating these error functions we had the getBy*
functions use the getAllBy*
functions? Perhaps using firstResultOrNull
.
Sorry, I still haven't reviewed all the PR but this is just something else I noticed.
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.
Yep that makes sense!
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.
Wow, this is so good. Thank you so much for the contribution! 🎉
Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the |
🎉 This PR is included in version 1.10.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
Adds "all" methods for:
Why:
#27
How:
Checklist:
Sidenote
If these
getAll
methods are added, thequeryBy
methods seem kind of redundant - instead of checking ifqueryBy
returnsnull
, you can check ifgetAll
is[]
.