Answers for "jest expect check exception"

CSS
1

jest expect error type

test("Test description", () => {
  expect.assertions(2);
  try {
      throw new TypeError("UNKNOWN ERROR");
  } catch (e) {
  	expect(e).toThrow(TypeError);
    expect(e.message).toBe("UNKNOWN ERROR");
  }  
});
Posted by: Guest on July-17-2021
0

jest test try catch

expect(() => {
   const model = new Sample(resolvedSample)
}).toThrow(TypeError);
Posted by: Guest on June-25-2020

Browse Popular Code Answers by Language