중첩 구성 요소에서 툴팁 및 모달을 사용하고 있으며, 사양 파일에서 테스트 모듈에 NgbModule.forRoot()
을 가져옵니다.테스트를 실패하게하는 구성 요소에서 NgbModule.forRoot()를 사용합니다.
이이 하나 개의 구성 요소를 제외하고 모든 곳에서 작동하는 것 같다, 나는이 가져 오기를 추가하면, 내 단위 테스트의 많은 갑자기이 오류와 함께 실패 시작 :
TypeError: this._unregisterListenersFn is not a function
at NgbTooltip.ngOnDestroy
을 내가 번들에 대한 각도 CLI를 사용하고 있습니다/테스트.
이것은 내 테스트에 실패한 유일한 구성 요소입니다.
또한 툴팁/모달 모듈을 개별적으로 가져와 해당 관련 제공 업체를 별도로 가져 오려고 시도했지만 위의 오류가 계속 발생합니다. forRoot()
없이 시도하면 DI 오류가 발생합니다.
나는 문제가 무엇인지 전혀 모른다.
다음은 스펙 파일입니다 :
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { APP_BASE_HREF } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { NgbModule, NgbTooltipModule, NgbTooltipConfig, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbModalStack } from '@ng-bootstrap/ng-bootstrap/modal/modal-stack';
import { ListItemComponent } from './list-item.component';
import { VideoPlayerService } from '../../../video-player';
import { CalendarRoutingService } from '../../calendar-routing.service';
describe('ListItemComponent',() => {
let component: ListItemComponent;
let fixture: ComponentFixture<ListItemComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
ListItemComponent
],
imports: [RouterTestingModule, NgbModule.forRoot()],
providers: [
VideoPlayerService,
CalendarRoutingService,
// NgbModalStack,
// NgbTooltipConfig
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListItemComponent);
component = fixture.componentInstance;
component.item = { records: [] };
fixture.detectChanges();
});
it('should create',() => {
expect(component).toBeTruthy();
});
});