I have been working on making assertions with jest mocked functions, and here is the code I am using:
const mockSaveProduct = jest.fn((product) => {
//some logic
return
});
jest.mock('./db', () => ({
saveProduct: mockSaveProduct
}));
The assertion I want to make is:
expect(mockSaveProduct.mock.calls[0][0]).toBe(product)
However, I encountered the following error:
ReferenceError: Cannot access 'mockSaveProduct' before initialization at the line saveProduct: mockSaveProduct