How to trigger an event in stub? [vue-test-utils]

You can use the .native modifier on the my-custom-form component to listen for the native DOM event instead of a custom submit event. From the docs ..

There may be times when you want to listen directly to a native event on the root element of a component. In these cases, you can use the .native modifier for v-on.

So the following should work in your case ..

<my-custom-form @submit.native.prevent="save"></my-custom-form>

EDIT: See @writofmandamus's comment and @JaredMcAteer's answer below for a better solution.


From @writofmandamus, in the comments of the accepted answer, provided a more general use answer, since changing the event binding to .native may not be possible or desired.

You can emit an event from a component stub with:

wrapper.find('my-custom-component-stub').vm.$emit('custom-event');