#Mocking - hiting catch from HttpService.get()

8 messages · Page 1 of 1 (latest)

hearty pivot
#

Any Ideas how I can hit the catch block? I can change it to observable if necessary

amber sail
#

Instead of using of, use throwError() from rxjs to cause an exception and the lastValueFrom to move to the .catch

hearty pivot
amber sail
#

Use throwError(() => new Error('error'))

#

throwError is fine, it's just the form that is being used IIRC

hearty pivot
#

ok so given this code

#

this is the new test:

#

it passed, just wondering if there is a better or cleaner way of doing this