I believe something fundamentally wrong in my understanding for Javascript.
In file abc.js, I have code
export function returnBoolean() {
return true;
}
export function output() {
return returnBoolean();
}
In the test, I do
import * as abc from "../abc";
it("test", () => {
abc.returnBoolean = jest.fn();
abc.returnBoolean.mockReturnValue(false);
expect(abc.returnBoolean()).toBe(false); // This is success
expect(abc.output()).toBe(false); // This failed because return is true
});
I don't know why
abc.output()
return is true
.
I am really confused. Any thought is really appreciated. Thanks!