You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a component with a simple link and I want to test that a click on it triggers a method. With Vue test util + jest, the method is called but not the spy.
Version of vue-test-utils : 1.2.0
Steps to reproduce
import { shallowMount } from '@vue/test-utils'
// The component to test
const LinkComponent = {
template: '<a href="www.google.fr" _target="_blank" @click="trackClick">My link</a>',
methods: {
trackClick() {
console.log('Track click')
},
},
}
it('Should call trackClick when link is clicked', async () => {
const wrapper = shallowMount(LinkComponent)
const spyTrackClick = jest.spyOn(wrapper.vm, 'trackClick')
const link = wrapper.find('a')
await link.trigger('click')
expect(spyTrackClick).toBeCalled()
})
Expected behaviour
Spy should be called
Actual behaviour
console.log is called and displayed in console & spy is not called
I can reproduce this issue with a ,