TOThomas Obermüllerinthmsobrmlr.hashnode.dev·Jun 6, 2021 · 1 min readMocking console.log with jestdescribe("outer", () => { describe("inner", () => { let spy: jest.SpyInstance; beforeAll(() => { spy = jest.spyOn(global.console, "log").mockImplementation(); }); afterAll(() => { spy.mockRestore(); }); it("do...00
TOThomas Obermüllerinthmsobrmlr.hashnode.dev·Jun 6, 2021 · 1 min readUsing jest toThrow with async / awaitInstead of it("doesn't work", async () => { const fn = async () => { throw new Error(); }; expect(await fn()).toThrow(); }); Use it("does work", async () => { const fn = async () => { throw new Error(); }; await expect(fn()).r...00