尝试改用匿名函数:
expect( function(){ parser.parse(raw); } ).toThrow(new Error("Parsing is not possible"));您应该将函数传递给
expect(...)调用。您的错误代码:
// incorrect:expect(parser.parse(raw)).toThrow(new Error("Parsing is not possible"));正在尝试实际 调用
parser.parse(raw)以将结果传递到
expect(...),



