jest.spyOn(console, "log"); describe("index", () => { beforeEach(() => { jest.clearAllMocks(); }); it("should log hello world", async () => { (console.log as jest.MockedFn).mockImplementation(() => { return; }); await import("./index"); expect(console.log).toHaveBeenCalledTimes(1); expect(console.log).toHaveBeenLastCalledWith("Hello world!"); }); });