I am relatively new to using Jasmine and have been experimenting with the toThrowError() function. However, I can't seem to get my test to pass successfully.
In one of my functions, I purposely throw an error:
test.service.ts
test(list:{}){
if(list == null){
throw new TypeError();
}
else{
// do something...
}
}
Here is my test code:
it('should throw an error', inject()
[
TestService
],
(
testService: TestService
) => {
let test = testService.test(null);
expect(test).toThrowError(TypeError);
}
);
Unfortunately, my test is failing with an Uncaught TypeError (I have tried calling it within a try-catch block).