Typescript and Jest: Avoiding type errors on mocked functions

Posted by Editorial Staff | Updated on

Typescript and Jest: Avoiding type errors on mocked functions Add this line of code const mockedAxios = axios as jest.Mocked. And then use the mockedAxios to call the mockReturnValueOnce. With your code, should be done like this:


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