The tested file uses a function that is imported from another file
import {myFunc} from './myFile'
How can I mock return value for this function in my tests for this file? I'm using jest.
The tested file uses a function that is imported from another file
import {myFunc} from './myFile'
How can I mock return value for this function in my tests for this file? I'm using jest.
This is what worked for me, I'm not sure if it's a good practice tho:
import * as myFile from "./myFile";
jest.mock("./myFile");
myFile.myFunc = jest.fn().mockImplementation(() => {
return "Some Value";
});