小编Vis*_*ani的帖子

Error: InvalidPipeArgument: 'function () { return fn.apply(this, arguments); }' for pipe 'AsyncPipe' Angular 7 Unit testing

I'm writing unit test cases in Angular 7 in this process got stuck to create unit test for a service variable 'isLoading'.

here is my app component html file:

<router-outlet></router-outlet>


<div *ngIf="guestUserService.isLoading | async"  class="loaderdiv">
  <mat-spinner class="loader"></mat-spinner>
</div> 
Run Code Online (Sandbox Code Playgroud)

The service file:

export class GuestUserService {

  public isLoading: any = new BehaviorSubject(false);

}
Run Code Online (Sandbox Code Playgroud)

The unit test case:

 fdescribe('AppComponent', () => {
         let guestUserService: any;
         let guestUserServiceSpy: any;

          beforeEach(async(() => {
            guestUserService = jasmine.createSpyObj('GuestUserService', ['isLoading']);
            TestBed.configureTestingModule({
              providers: [
                { provide: GuestUserService, useValue: …
Run Code Online (Sandbox Code Playgroud)

unit-testing typescript karma-jasmine angular

5
推荐指数
1
解决办法
3021
查看次数

标签 统计

angular ×1

karma-jasmine ×1

typescript ×1

unit-testing ×1