Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
it('should throw if the backend returns an error ', () => {
let bubblesUpTheError = false;
serviceUnderTest.getFavoriteMovies().subscribe(() => {}, () => (bubblesUpTheError = true));
const req = http.expectOne(environment.favoriteUrl, 'expected to make a request');
expect(req.request.method).toEqual('GET');
req.flush('ERROR', { status: 500, statusText: 'Internal server error' });
expect(bubblesUpTheError).toBeTruthy();
http.verify();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.