-
Notifications
You must be signed in to change notification settings - Fork 412
Implement toBeInvalid
& toBeValid
matchers
#110
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
Conversation
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.
Looking great. Just a couple of comments requesting to add more documentation or links to documentation and issues.
I added linked resources to the README.md. I will at least document why it's there. |
Ok, so finally I was able to remove the specific testing I created earlier. Every test passed, so I think the upgrade should not be an issue. |
Hmm… The test is completed without any issue on my local machine… :/ |
Cool! I will revert my last commit and push it again. |
@gnapse I just rebased the branch to remove the last commit 👍 |
🎉 This PR is included in version 3.4.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
This pull-request is a proposed implementation for the custom matchers
toBeInvalid
andtoBeValid
.Why:
This is following a discussion we quickly had with the issue #108.
These two custom matchers can avoid folks to check with different expect tests:
aria-invalid
not equal tofalse
checkValidity
is returningfalse
How:
toBeInvalid
checks if one of these are correct:aria-invalid
exists and if the value is not equal tofalse
(as each value different than false are considered true (ref))the targetted element is a form element and
checkValidity()
returnsfalse
toBeValid
checks if all of these are correct:aria-invalid
is not part of the markup or the value is equal tofalse
if the targetted element is a form element,
checkValidity()
returnstrue
Checklist:
I do not know if it's a good practice, please let me know your thoughts about that: I had to use
jsdom
to be able to test if these two custom matchers are correctly checking.checkValidity()
.Without it,
.checkValidity()
was always returningtrue
even when theinput
had an invalid value.