Jest unit testing a function throwing error
问题 I was trying to unit test a function in node which throws an error regardless of any condition. Here is my node function definition. public testFunction() { throw new Error('Test Error'); } As you can see this function always throws an error whenever it has been called. I tried to execute unit testing to this function using jest .toThrow(error?) method. I was not able to unit test the function as expected. The below mentioned are the test cases that I wrote and have attached the screenshot of