vue test utils doesn't fire trigger

Viewed 190

I am trying to simulate a trigger event and test that it has actually fired, but I keep having an empty response.

this is the code:

<v-btn small class="elevation-0" 
     @click="$emit('close')">
        cancel
</v-btn> 
it('Should emit close when the CANCEL button is clicked', () => {
    const wrapper = shallowMount(TaskForm, {
      propsData: {
        teamMembers: project.teamMembers,
        task: new Task({ project, name: '' })
      }
    });

    wrapper.findComponent(VBtn).trigger('click');

    expect(wrapper.emitted()).toHaveProperty('close');
  });

Ok I have found the solution: basically trigger cannot be called on a component, therefore I have opted for component.vm.$emit('click') that does the job the right way

0 Answers
Related