Angular service testing: Cannot find name ‘asyncData’

Change this line:

httpClientSpy.get.and.returnValue(asyncData(expectedHeroes));

to use the Observable operator of()

httpClientSpy.get.and.returnValue(of(expectedHeroes));

This will return an observable that can be subscribed to and will return expectedHeroes. If you are using Angular 6, you can import this directly from rxjs:

import {of} from 'rxjs';

Leave a Comment

File not found.