I beginning to try jasmine and I want to use the toThrowError() function but my test does not want to succeed.
I have one function where I throw an error:
test.service.ts
test(list:{}){
if(list == null){
throw new TypeError();
}
else{
// do something...
}
}
And my test :
it('shall throw an error', inject()
[
TestService
],
(
testService: TestService
) => {
let test = testService.test(null);
expect(test).toThrowError(TypeError);
}
);
And my test fails with an Uncaught TypeError (when I call it I'm doing it in a try catch).