2016-11-29 2 views
0

각도 2로 구성 요소를 테스트하려고하는데 종속성로드 문제가 있습니다.각도 2 테스트 종속성

을 테스트 할 때 UserModule을 가져 오려고하면 갈마 오류가 발생하며 가져 오지 않으면 구성 요소 오류가 많이 발생합니다.

테스트 설정

는 각-CLI가 생성 내 특정 시험이 (가)

import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 
import { By } from '@angular/platform-browser'; 
import { DebugElement } from '@angular/core'; 

import { UserModule } from '../../user.module'; 
import { UserShowcaseComponent } from './user-showcase.component'; 

describe('UserShowcaseComponent',() => { 
    let component: UserShowcaseComponent; 
    let fixture: ComponentFixture<UserShowcaseComponent>; 

    beforeEach(async(() => { 
     TestBed.configureTestingModule({ 
      imports: [UserModule],  <---------------------------------- NOTE 
     }) 
      .compileComponents(); 
    })); 

    beforeEach(() => { 
     fixture = TestBed.createComponent(UserShowcaseComponent); 
     component = fixture.componentInstance; 
     fixture.detectChanges(); 
    }); 

    it('should create',() => { 
     expect(component).toBeTruthy(); 
    }); 
}); 

다음 카르마에서 오류가 단순히 무엇이며이 (이 어떤 테스트가 실행되지 않습니다 전체 출력) :

29 11 2016 16:49:40.478:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/ 
29 11 2016 16:49:40.479:INFO [launcher]: Launching browser Chrome with unlimited concurrency 
29 11 2016 16:49:40.649:INFO [launcher]: Starting browser Chrome 
29 11 2016 16:49:42.010:INFO [Chrome 53.0.2785 (Linux 0.0.0)]: Connected on socket /#Jpv1IioGnou6CQtUAAAA with id 98117142 
Chrome 53.0.2785 (Linux 0.0.0) ERROR 

답변

0

카르마가 공급 업체 파일을로드하지 않아 문제가 제대로보고되지 않는 문제가있었습니다. 이보고 문제는 angular-cli 1.0.0-beta.20으로 수정되었습니다 (this commit 참조).

용액에 files

{ pattern: './node_modules/jquery/dist/jquery.min.js', watched: false } 

추가 제 경우 karma.conf.js에 공급 libs와 추가하는 것이다.

예, jquery를 사용해서는 안된다는 것을 알고 있습니다.