Do an import * as
of your utility file that you can then mock individual functions of for testing.
import * as utils from "./PageTransitionUtil";
jest.mock("./PageTransitionUtil");
utils.goToSecondPage = jest.fn();
From here the goToSecondPage
is a mock function that you can do assertions on, i.e. expect(utils.goToSecondPage).toHaveBeenCalled()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…