import * as app from "./App" import * as math from "./src/math" describe(" Mock Function provides 3 features",()=>{ test("3-1.Change the implementation 実装を変更する mockImplementation()",()=>{ const mock = jest.fn().mockImplementation(() => "bar") expect(mock("foo")).toBe("bar") expect(mock).toHaveBeenCalledWith("foo") }) test("3-2.Change the implementation 実装を変更する1回",()=>{ const mock = jest.fn().mockImplementationOnce(() => "bar") expect(mock("foo")).toBe("bar") expect(mock).toHaveBeenCalledWith("foo") expect(mock("baz")).toBe(undefined) expect(mock).toHaveBeenCalledWith("baz") }) test("3-3.Change the implementation 実装を変更する promise",()=>{ const mock = jest.fn() mock.mockResolvedValue("bar") expect(mock("foo")).resolves.toBe("bar") expect(mock).toHaveBeenCalledWith("foo") }) })