📜  开玩笑的期望错误类型 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:13.012000             🧑  作者: Mango

代码示例1
test("Test description", () => {
  expect.assertions(2);
  try {
      throw new TypeError("UNKNOWN ERROR");
  } catch (e) {
      expect(e).toThrow(TypeError);
    expect(e.message).toBe("UNKNOWN ERROR");
  }  
});