I need assistance writing a simple test in Angular using Shallow render. In my HTML template, I am utilizing the Async pipe to display an observable. However, I keep encountering the following error:
Error: InvalidPipeArgument: '() => this.referenceDataService.getRoutes()
.pipe(Object(rxjs_operators__WEBPACK_IMPORTED_MODULE_5__["map"])((routes) => { debugger; return routes || []; }))' for pipe 'AsyncPipe'
Component:
routes$: Observable<RouteModel[]>;
routes$ = () => this.referenceDataService.getRoutes()
.pipe(map((routes: RouteModel[]) => {
debugger;
return routes || [];
}));
test:
beforeEach(() => {
routes = [
{ routeId: 1, prefix:'/test1', route:'/test1' },
{ routeId: 2, prefix:'/test2', route:'/test2' }
]
dataServiceMock = {
getRoutes: () => of(routes)
};
shallowComponent = new Shallow(RouteComponent, AppModule)
.provideMock([
{ provide: ReferenceDataService, useValue: dataServiceMock}
])
.dontMock([FormBuilder]);
});
it('should create', async () => {
const { instance } = await shallowComponent.render();
expect(instance).toBeTruthy();
});
If anyone could provide insight into what the issue might be, I would greatly appreciate it.
Thank you