Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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");
  }  
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jest #expect #error #type
ADD COMMENT
Topic
Name
1+9 =