Use and expose a local copy of fireEvent#75
Conversation
| 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.
"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.
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.
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.
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.
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
fireEventfrom DOM Testing Library is giving us a hard time trying to makeuser-eventusable 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.