[Vuejs]-Can't passed a vue js unit test made with jest

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

Leave a comment