1👍
✅
Try to spy the method instead.
it('Call getIngredients function when the component is mounted', async () => {
const getIngredientsMock = jest.spyOn(CocktailCard.methods, 'getIngredients')
const wrapper = shallowMount(CocktailCard, {
propsData: {
c**ktail: {
idDrink: '1',
strDrink: 'Mojito',
}
},
})
expect(getIngredientsMock).toHaveBeenCalled()
})
👤lars
Source:stackexchange.com