Answer the question
In order to leave comments, you need to log in
How can I mock preventDefault on vm.$emit in Jest and vue-test-utils?
Good day.
There is a simple component that looks something like this.
<template>
<v-link
href="#"
data-test="send-code"
@click.prevent="onClick"
>
{{ label }}
</v-link>
</template>
<script>
import VLink from '@vendor/ui/kit/VLink';
export default {
name: 'SendCode',
methods: {
onClick() {
// some stuff
this.$emit('click');
},
},
components: {
VLink,
},
};
</script>
wrapper.find('[data-test=send-code]').vm.$emit('click'); // fail! если убрать prevent, все заработает
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question