Class File
//Consumer class
class Consumer {
constructor(){
}
getConsumerData(){
//does something and does not return anything
}
}
Inside react component button click this method is being called
//ReactComponent.tsx
handleButtonClick() {
Consumer.getConsumerData();
}
Test File
const methodSpy = jest.spyOn(Consumer.prototype, "getConsumer").mockImplementation(()=>{});
expect(methodSpy).toHaveBeenCalled();