-
Notifications
You must be signed in to change notification settings - Fork 458
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
fix(ByLabelText): improve error message when label is associated with… #720
fix(ByLabelText): improve error message when label is associated with… #720
Conversation
… non-labellable elements (testing-library#716)
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 bc54893:
|
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.
Looks great to me! Just need to figure out the coverage issue. Looks like we may be missing a branch of code in the tests.
Codecov Report
@@ Coverage Diff @@
## master #720 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 635 646 +11
Branches 165 168 +3
=========================================
+ Hits 635 646 +11
Continue to review full report at Codecov.
|
Sorry about that. Changed an existing test slightly to cover this branch too. 😇 |
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.
Awesome. Thanks!
@all-contributors please add @ipap360 for code and tests |
I've put up a pull request to add @ipap360! 🎉 |
🎉 This PR is included in version 7.21.6 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
… non-labellable elements (#716)
What:
Add a more specific error message whenever getByLabelText/getAllByLabelText cannot find an associated element because the element is non-labellable.
Why:
The generic error message wasn't clear on why it was failing and whether this was changed on purpose (given that it was previously working).
How:
Whenever a label exists but no form control association is found, do an additional check for any other elements associated with the label via the "for" attribute. If there are, print specific error messages on why the query is failing and how to resolve this issue.
Checklist:
docs site N/A
My very first open source contribution 😊
Really happy that it is for a great project that I rely so much on 🥳