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
Fix/emitted events cache #1449
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. |
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.
Just one question about a possible additional assertion. Also, you might need to run prettier to ensure all the files are formatted correctly - I think the command you want is yarn lint:fix
(see package.json
).
|
||
const wrapper1 = mount(Foo) | ||
await wrapper1.trigger('click') | ||
expect(wrapper1.emitted('foo')).toHaveLength(1) |
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.
Should we also assert
expect(wrapper2.emitted('foo')).toHaveLength(0)
Here as well?
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.
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.
src/emit.ts
Outdated
@@ -11,7 +11,7 @@ const enum DevtoolsHooks { | |||
COMPONENT_EMIT = 'component:emit' | |||
} | |||
|
|||
let events: Events | |||
let events: 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.
Not directly relevant but as a refactor in the future, I wonder if we should use WeakMap
instead of a record here 🤔
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.
LGTM
The PR needs to be fixed for the linting issues.
I would also squash the commits, and mention that they fix issue #1445 in the commit message.
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.