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: add message if type/paste function is called with an invalid element #375
fix: add message if type/paste function is called with an invalid element #375
Conversation
If the user tries to call type function with an invalid element, an explicit error will be thrown. This error should be better then 'TypeError: Cannot read property 'length' of undefined'
Codecov Report
@@ Coverage Diff @@
## master #375 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 385 392 +7
Branches 111 113 +2
=========================================
+ Hits 385 392 +7
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.
I think we should also do this check in the currentValue function in type.
I'm looking the code better and maybe there could be other problems like this Lines 253 to 254 in 50e330b
Lines 286 to 287 in 50e330b
Maybe we should use |
Whatever you think makes the most sense 👍 |
I have made the changes. I have updated also paste function with this logic |
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. Thanks!
@all-contributors please add @marcosvega91 for code and tests |
I've put up a pull request to add @marcosvega91! 🎉 |
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 12.0.6 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
thank you @kentcdodds, it's awesome. I'm really happy to be part of another team of testing library 🥳 . Thank you for all the things that you are doing for the community and the opportunity that you give to all of us ❤️ |
What:
I have thrown a new
TypeError
if the user callsuserEvent.type
oruserEvent.paste
with an element that has no value.This PR is part of issue #356.
Why:
Because as it was before the PR the error was not very helpful
How:
By checking if the currentElement has value property.
The message thrown is like this
the current element is of type BODY and doesn't have a valid value
Checklist: