is there any way to throw an error as an object in jasmine? In my productive code i use the error object (that comes from request promise native) to log some information. And then i have a logger spy, that checks if the error was logged correctly. But when my test throws the error with a simple error message and my productive code wants to access err.response.headers i get a runtime error.
i already tried to use it like this
spy.and.throwError(new Error({...}))
But as the constructor from Error only takes a string as argument, it obviously does not work
spy.and.returnValue(Promise.reject({message: 'someError', response: {headers: 'abc'}}));solved the problem