Jest1 [Jest] Testing with Error Return Source Code Let's create a function to test. const funcWithError = (): void => { throw new Error("My Error") } Test Code Now, let's test our function. describe("Test With Error", () => { it("tests a function with an error return", () => { try { calculator.funcWithError(); } catch (err) { expect(err).toEqual(new Error("My Error")); } }); }); I tested with a try...catch statement. Yay~ It works we.. 2020. 12. 28. 이전 1 다음