2017-09-28 8 views
0

저는 각형 (angular-cli) 프로젝트가 있습니다.phantomjs가있는 카르마 테스트는 ngIf와 함께 실패합니다.

내가 테스트 할 HTML은 다음과 같습니다

<div *ngIf="!isMobile" class="shop-description"> 
    {{ description }} 
</div> 
<div class="shop-link"> 
    <span> 
    {{ link}} 
    </span> 
</div> 

테스트는 다음과 같이 :

beforeEach(() => { 
    fixture = TestBed.createComponent(ShopItemComponent); 
    component = fixture.componentInstance; 
    component.shop = ShopServiceMock.shops[0]; 
    component.isMobile = false; 
    fixture.detectChanges(); 
    }); 
    it('should have a title',() => { 
     fixture.detectChanges(); 
     const el = fixture.debugElement.nativeElement; 
     expect(el.querySelector('div.shop-title>span').innerText).toContain('test'); 
    }); 

    it('should have a description',() => { 
     fixture.detectChanges(); 
     const el = fixture.debugElement.nativeElement; 
     expect(el.querySelector('div.shop-description').innerText).toContain('love'); 
    }); 

명령을 모두 통과 '이 NG 시험'문제없이.

TypeError: null is not an object (evaluating 'el.querySelector('div.shop-description').innerText')

답변