4
테스트 구성 요소 인스턴스를 만드는 동안 오류가 발생합니다. 내가 오류 받고 있어요'DynamicTestModule'모듈에서 예기치 않은 'DecoratorFactory'값 가져 오기 - karma-jasmine
let comp: TaskviewComponent;
let fixture: ComponentFixture;
let deTaskTitle: DebugElement;
let elSub: HTMLElement;
describe('TaskviewComponent',() => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
TaskviewComponent
],
imports: [
NgModule,
RouterTestingModule,
TranslateModule.forRoot(),
],
providers: [
RestDataService,
Restangular,
{provide: OAuthService, useClass: OAuthServicMock},
{provide: ComponentFixtureAutoDetect, useValue: true},
{provide: UserInfoService, useClass: UserInfoServiceMock},
{
provide: LocalStorageService, //provide: LOCAL_STORAGE_SERVICE_CONFIG,
useValue: {
prefix: ApplicationConstants.ANGULAR2_LOCAL_STORAGE_ID,
storageType: 'sessionStorage'
}
}],,
})
fixture = TestBed.createComponent(TaskviewComponent);
comp = fixture.componentInstance;
deTaskTitle = fixture.debugElement.query((By.css('.Subject')));
elSub = deTaskTitle.nativeElement;
});
it('should have a subject',() => {
expect(elSub.textContent).toContain('Client Data Maintenance2 ');
});
});
: 예기치 않은 값은 'DecoratorFactory'모듈 'DynamicTestModule'오류로 수입했다. "fixture = TestBed.createComponent (TaskviewComponent);"를 제거하면 오류가 해결됩니다. 그러나 이것은 테스트 구성 요소를 생성하지 않습니다. 또한 NgModule을 imports []에 포함시키지 않으면 Ngmodel, datepicker 등과 같은 요소가 인식되지 않습니다.
Angular 및 Emmet에 Bootstrap 4를 사용하는 경우 Emmet에 NgModule이 자동 채워지고 NgbModule 대신 허용됩니다. 보시다시피 그들은 철자가 가까워서 일어날 수 있습니다. 이것은 내가 한 일이며, 다른 사람들이이 문제를 가지고있는 경우를 대비하여 공유 할 것이라고 생각했습니다. –