-
Notifications
You must be signed in to change notification settings - Fork 669
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
Unable to trigger custom event #1239
Comments
older issue on the topic: #145 |
I managed to bypass this limitation by passing the event through in a stub: <!-- "open" is a custom event triggered by watching -->
<!-- the `open` attribute on the wrapped dialog. -->
<DialogWrapper @open="doStuff" /> it('does stuff when dialog is opened', () => {
const wrapper shallowMount(MyComponent, {
stubs: {
DialogWrapper: `<dialog @open="$emit('open')" />`,
},
});
wrapper.trigger('open');
// Assuming we have all spies set up.
expect(wrapper.vm.doStuff).toHaveBeenCalled();
}); Note the <div @myEvent="$emit('myEvent')"> |
Hey, I am sorry but from what I see, this should work? @lmiller1990 @JessicaSachs am I missing something here? Trigger works both on custom and native events. |
Should you be doing Also join https://vue.land/ it is very active! There is a #testing channel. |
I've also had this issue. This, however, has worked for me const input = wrapper.find('something-stub');
input.vm.$emit('foobar'); |
Version
1.0.0-beta.29
Reproduction link
http://no-link
pasting code instead:
Steps to reproduce
I used .trigger to trigger an 'input' event for a custom child component I am testing. I need to pass a payload with an array of integers. (or just one integer). Do I use .trigger or wrapper.vm.$emit ? How can I debug this?
What is expected?
I used .trigger to trigger an 'input' event for a custom child component I am testing. I need to pass a payload with an array of integers. (or just one integer). Do I use .trigger or wrapper.vm.$emit ? How can I debug this?
What is actually happening?
The event isnt triggered correctly
other comments
The discord help channel is practically deserted. We beg for some help, I've been using vue-test-utils for 2 years, still in beta, and help is really scarce..
The text was updated successfully, but these errors were encountered: