How to mock an asynchronous function call in another class?

Posted by Jessica Taylor | Updated on

If you want to mock an asynchronous function call in another class? You could potentially abstract the new keyword away using a SalesService.create() method, then use jest.spyOn(object, methodName) to mock the implementation.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers