-
Notifications
You must be signed in to change notification settings - Fork 111
Use and expose a local copy of fireEvent #75
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
src/vue-testing-library.js
Outdated
fireEvent[fn] = async (...params) => { | ||
fireEvent[`_${fn}`](...params) | ||
// Vue Testing Library's version of fireEvent will call DOM Testing Library's | ||
// version of fireEvent plus wait for one tick of the event loop so 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.
"so that..."
couldn't come up with a good wording to explain why waiting for a tick is needed. Any ideas?
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'd love to know, too, whether if making fireEvent return a promise is totally necessary due to Vue internals. There might be some alternative that keeps VTL public API as similar as possible to RTL's and DTL's.
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.
Any ideas?
How about "to allow vue to asynchronously handle the event"?
Maybe it would make sense to link to the docs here: https://vuejs.org/v2/guide/reactivity.html#Async-Update-Queue
Good question on if it is necessary for fireevent to be async. Both React and Preact expose ways of forcing them to flush their update queues synchronously. Maybe it is worth looking into vm.$forceUpdate
to see if it does what we want
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.
How about "to allow vue to asynchronously handle the event"?
Sounds good! Added.
I'm gonna give vm.$forceUpdate
(or even nextTick
? who knows) a go. I'd really love to stick to synchronous events.
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.
Might also be worth looking into vuejs/vue-test-utils#1137
Codecov Report
@@ Coverage Diff @@
## master #75 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 61 62 +1
Branches 10 10
=====================================
+ Hits 61 62 +1
Continue to review full report at Codecov.
|
Thanks for the approval @dfcook! Merging this one. Are you publishing a new major version? |
2.0.0 released |
As suggested in testing-library/user-event#153, VTL mutating
fireEvent
from DOM Testing Library is giving us a hard time trying to makeuser-event
usable in VTL. Also, I'd say that mutating an imported object isn't the safest strategy.I've also added a bunch of tests for the "new"
fireEvent
.This is not a breaking change.Actually, it is.fireEvent()
now returns a Promise, and it didn't.