-
Notifications
You must be signed in to change notification settings - Fork 664
Closed
Description
Version
1.0.0-beta.29
Reproduction link
https://github.com/lee-chase/vue-test-utils-listeners
Steps to reproduce
Given a simple button wrapper component
<template>
<button v-bind="$attrs" v-on="$listeners">
<div class="content">{{ buttonText }}</div>
</button>
</template>
I have been unable to test the click event as follows:
it("Raises click event when clicked", () => {
const wrapper = shallowMount(MyButton2);
wrapper.find("button").trigger("click");
expect(wrapper.emitted().click).toBeTruthy();
});
If I change the component to explicitly handle clicky it works, but this is not desirable for native component wrappers and negates the usefulness of $listeners
<template>
<button v-bind="$attrs" v-on="$listeners" @click="$emit('click')>
<div class="content">{{ buttonText }}</div>
</button>
</template>
What is expected?
It should be possible to test events surfaced through $listeners
What is actually happening?
No event is raised
danielelkington, ferreira-mariana and sw517
Metadata
Metadata
Assignees
Labels
No labels