Closed
Description
Subject of the issue
When I trigger a click event on a component when spying a function, the function is called, but the spy does not work
Steps to reproduce
Here is my component:
<template>
<button class="close-btn no-select" @click="close" @keydown.esc="close" />
</template>
<script>
export default {
name: 'CoreCloseButton',
methods: {
close() {
this.$emit('close')
},
},
}
</script>
Here is my test:
import { shallowMount } from "@vue/test-utils"
import CoreCloseButton from "./CoreCloseButton"
describe("CoreCloseButton.vue", () => {
it('Should call close method when click on button', async () => {
const wrapper = shallowMount(CoreCloseButton)
let spyClose = jest.spyOn(wrapper.vm, 'close')
await wrapper.trigger('click')
expect(spyClose).toBeCalled()
})
})
Expected behaviour
The spy should be called
Actual behaviour
The spy is not called
Metadata
Metadata
Assignees
Labels
No labels