How to test that an angular factory function using a promise is throwing an error in jasmine
- 阅读更多 关于 How to test that an angular factory function using a promise is throwing an error in jasmine
Here's how my function looks like. var myFunc = function(){ return functionReturningaPromise() .then(function(){ //success, doesn't matter what happens here }) .catch(function(err){ //handle error here and then throw to handle higher throw new Error('Error in my function'); }) } I need the function to be this way to handle an error inside this function and then throw an error to handle on higher level. But i don't know how to test it with jasmine. I know how to control the promises for testing and my basic set up looks like this: it('Should throw an error', inject(function(alert) { var