-
Notifications
You must be signed in to change notification settings - Fork 668
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
Testig window/document events #230
Comments
Hi, thanks for the detailed bug report. This is related to this bug — #215. It should be fixed in the next beta release 😀 |
Awesome! Thanks! 🙏 |
I am not sure if it was related to that issue, but the following example works for me: it('should emit close event on esc', () => {
const component = {
created () {
window.addEventListener('keydown', this._closeOnEsc)
},
methods: {
close () {
this.$emit('close')
},
_closeOnEsc (e) {
if (e.keyCode === 27) {
this.close()
}
}
}
}
const wrapper = mount(component, {
attachToDocument: true
})
wrapper.trigger('keydown.esc')
expect(wrapper.emitted().close).to.be.ok
}) @apertureless make sure you use |
Much thanks @wtho ! 🙏 |
but anyway, it points me to it, thanks 🙏🙂 |
Maybe I missed something, but is there a way to test EventListeners?
I have following component
It is working in storybook so far, that if you set the prop to true and press esc that the
close
event is emitted.It works also if I test against the button which has
@click="close()"
Here are the tests
The first test with the button is working. However not the second one.
The text was updated successfully, but these errors were encountered: