-
Notifications
You must be signed in to change notification settings - Fork 469
Adds matcher name to multiple elements error #677
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
Adds matcher name to multiple elements error #677
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1febc64:
|
Love it. Thanks! Could you add a test for this as well? |
There did not appear to be a test explicitly covering the multiple element error in the first place so I've added a new one |
Looks like we're not quite there on coverage. Let me know if you need help identifying what's left. |
Just pushed up the missing test |
Codecov Report
@@ Coverage Diff @@
## master #677 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 596 602 +6
Branches 148 151 +3
=========================================
+ Hits 596 602 +6
Continue to review full report at Codecov.
|
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.
Cool 👍
@all-contributors please add @jacobparis for code and tests |
I've put up a pull request to add @jacobparis! 🎉 |
🎉 This PR is included in version 7.18.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
The getByRole queries are designed to return a single element whose role matches the provided role argument and whose accessible name matches the provided name argument.
When multiple elements are matched, the language in the error message only mentions the role and not the accessible name.
Sample query
Current error message
New error messages
Why:
When you have several queries against the same role but for different accessible names, the error messages produced by them are identical. The only way to figure out which name is finding duplicates is to look at the code trace.
How:
The information including the accessible name parameter was already provided to the error message handler. The logic for displaying the name with or without quotes depending on its type was already present in the
getMissingError
handler, so I copied it to thegetMultipleError
handlerChecklist:
docs site N/A