I want to test the error handling in my Angular2 component and therefore want to mock a service to return an Observable.throw(\'error\'). How can that be done using Jasmine and
Here is my solution for the ones using Rxjs 6
let mockService = { getData: () => { return of({data:'any data'}); } } spyOn(mockService , 'getData').and.callFake(() => { return throwError(new Error('Fake error')); });