Repository navigation
Fix/emitted events cache - #1449
Conversation
✅ Deploy Preview for vue-test-utils-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
|
||
| const wrapper1 = mount(Foo) | ||
| await wrapper1.trigger('click') | ||
| expect(wrapper1.emitted('foo')).toHaveLength(1) |
There was a problem hiding this comment.
Should we also assert
expect(wrapper2.emitted('foo')).toHaveLength(0)Here as well?
There was a problem hiding this comment.
We would have to wait until after wrapper2 is mounted. We can do that, but the ultimate point of the test is to ensure that subsequent mounts no longer clear the emit history for previously mounted components.
| } | ||
|
|
||
| let events: Events | ||
| let events: Events = {}; |
There was a problem hiding this comment.
Not directly relevant but as a refactor in the future, I wonder if we should use WeakMap instead of a record here 🤔
Refactoring attachEmitListener function to not clear entire emitted events history on every call. A new removeEventHistory has been exposed and added to the unmount method logic so that specific emit history will be cleared on wrapper unmount. Unit testing has been added as well to show that the bug has been fixed. fixes issue vuejs#1445
6ac9659 to
193a0f4
Compare
|
Thanks @BrettLargent ! |
No problem! Thank you all for your responsiveness and feedback. Glad we got this squashed quickly 💯 |
|
I will release this soon! Please wait a few days. |
|
Hey all! It's been a while since this was merged, but I'm still having the same problems with v0.17.1. Can anyone confirm whether this was ever released for me? Thanks! |
|
Yes it has been released. Are you using VTU v2.0.2? |
|
🤦♂️ nope, I was updating the wrong dependency. Sorry for that! |
Refactoring attachEmitListener function to not clear entire emitted events history on every call. A new removeEventHistory has been exposed and added to the unmount method logic so that specific emit history will be cleared on wrapper unmount. Unit testing has been added as well to show that the bug has been fixed.