Try using an anonymous function instead:
expect( function(){ parser.parse(raw); } ).toThrow(new Error("Parsing is not possible"));
you should be passing a function into the expect(...)
call. Your incorrect code:
// incorrect:
expect(parser.parse(raw)).toThrow(new Error("Parsing is not possible"));
is trying to actually call parser.parse(raw)
in an attempt to pass the result into expect(...)
,
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…