Reputation: 23
For example, how to trigger a change event in v-autocomplete inside your component, so that I
I tried something like:
import SomethingAutocomplete from "@/components/SomethingAutocomplete.vue";
import { shallowMount } from "@vue/test-utils";
import { VAutocomplete } from "vuetify/lib";
import { Constructor } from "vue/types/options";
test("Some test", async () => {
const wrapper = shallowMount(SomethingAutocomplete);
let ac = wrapper.find(<Constructor>VAutocomplete);
ac.trigger("input");
await wrapper.vm.$nextTick();
...
<handler was never called>
});
Any hints? TIA.
Upvotes: 1
Views: 568
Reputation: 1417
trigger()
is only used to trigger event inside the component. Since here we want to check the behaviour on an event emitted by a child, we need to emit the event to the parent component.
So this will do the job :
ac.vm.$emit("input", valueOfTheInput);
Upvotes: 1