-
Notifications
You must be signed in to change notification settings - Fork 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
Warn when users are using fireEvent.input or .change directly #166
Conversation
Codecov Report
@@ Coverage Diff @@
## master #166 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 88 92 +4
Branches 28 30 +2
=========================================
+ Hits 88 92 +4
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.
Looks great! Left a small note on the specifics of the warning message
src/vue-testing-library.js
Outdated
|
||
Object.keys(dtlFireEvent).forEach(key => { | ||
fireEvent[key] = async (...args) => { | ||
if (changeOrInputEventCalledDirectly(args[1], key)) { | ||
console.warn( | ||
'By using "change" or "input", there may be unexpected issues. Please use "update" for a better experience.', |
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.
A small suggestion to (1) write down the used event key (so people have a better feedback on where to look for) and (2) to display "fireEvent.", so that people have the exact answer right there in the warning. Any other suggestion is welcome :)
'By using "change" or "input", there may be unexpected issues. Please use "update" for a better experience.', | |
`Using "fireEvent.${key} may lead to unexpected results. Please use fireEvent.update() instead.`, |
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.
This makes sense, I'll make that change, thanks!
src/vue-testing-library.js
Outdated
|
||
Object.keys(dtlFireEvent).forEach(key => { | ||
fireEvent[key] = async (...args) => { | ||
if (changeOrInputEventCalledDirectly(args[1], key)) { | ||
console.warn( | ||
`Using "fireEvent.{$key} may lead to unexpected results. Please use fireEvent.update() instead.`, |
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.
it should actually be
`Using "fireEvent.{$key} may lead to unexpected results. Please use fireEvent.update() instead.`, | |
`Using "fireEvent.${key} may lead to unexpected results. Please use fireEvent.update() instead.`, |
so that it renders "change" or "input" 😉
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.
Thanks for catching that!
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.
👍 neat!
🎉 This PR is included in version 5.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 6.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.