I found that this still not mocking my function, when I console.log the module, it is still using real implementation.
jest.mock('./myFile', () => {
const actual = jest.requireActual('./myFile');
return {
...actual,
firstAsyncFunction: jest.fn(),
secondAsyncFunction: jest.fn(),
};
});
it('outputs correctly', async () => {
(firstAsyncFunction as jest.Mock).mockResolvedValue('value1');
(secondAsyncFunction as jest.Mock).mockResolvedValue('value2');
await act();
expect(firstAsyncFunction as jest.Mock).toBeCalled();
expect(secondAsyncFunction as jest.Mock).toBeCalled();
});