0

嗨,我无法测试 runOutsideAngular 中的代码我得到 component.dateFormat 为未定义任何想法如何解决它?

private setDateTime(): void {
    
      this.zone.runOutsideAngular(() => {
          this.dateFormat = 'sample';
      });
   
  }

这是我的单元测试

  it('should render date',  fakeAsync (()  => {
    spyOn(fixture.ngZone, 'runOutsideAngular').and.callFake((fn: Function) => fn());
    
   
    fixture.ngZone.runOutsideAngular(() => {
      fixture.detectChanges();
      flush();
      console.log('flushdas1', component.dateFormat);
    })

    expect(true).toBeTruthy();
  }));
4

0 回答 0