0
votes

I am running the unit test for an angular app. I expect ngOnInit to be called, but the test fails as TypeError: Cannot read property 'subscribe' of undefined.

This is Component.ts

ngOnInit() {
    this.topToolBarService.change.subscribe(customer => {
      this.filter.customerid = customer;
      this.customerid = customer;
      this.getData();

    });
}
1

1 Answers

0
votes

Is your service initialized?

Have you tried

this.topToolBarService.change().subscribe(...

best regards