I am using the function setMethods, it is still working, however I received the above message on the console. I am wondering what should be the new approach?.
It is being used to spy on a method and then see if it was called with the mocked parameters, here is the code:
const spyGenerateCalendar = jest.spyOn(wrapper.vm, 'generateCalendar');
const spyAxiosRequest = jest.spyOn(axios, 'get');
// setting methods for spying
wrapper.setMethods({generateCalendar: spyGenerateCalendar});
wrapper.vm.generateCalendar();
// Expecting calls
expect(spyGenerateCalendar).toHaveBeenCalled();
expect(spyAxiosRequest).toBeCalledWith(axiosRequestURL, axiosRequestParams);
It is unneeded. I am already spying on the method "generateCalendar" on the line:
const spyGenerateCalendar = jest.spyOn(wrapper.vm, 'generateCalendar');
So If the line wrapper.setMethods({generateCalendar: spyGenerateCalendar}); is removed. The result will be the same, so expect(spyGenerateCalendar).toHaveBeenCalled(); will be true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With