我想測試一個具有一些依賴關係的簡單組件。所以除其他我必須提供一些提供商 描述( 'AccountLookupComponent',()=> { 令組分:AccountLookupComponent; 設夾具:ComponentFixture enter code here
;Angular 2單元測試錯誤:無法解析所有參數DecoratorFactory :(?)
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
TestComponentWrapper,
AccountLookupComponent
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [HttpModule],
providers: [AccountLookupService, AuthHttp, AuthenticationService, AdalService, AdfsSecretService, CookieService, NgModule,
{ provide: 'IAccountLookupClient', useClass: AccountLookupClient },
{ provide: 'IApiClient', useClass: ApiClient },
{ provide: 'ITimeoutService', useClass: TimeoutService },
]
})
.compileComponents();
fixture = TestBed.createComponent(TestComponentWrapper);
component = fixture.debugElement.children[0].componentInstance;
fixture.detectChanges();
}));
it('should create',() => {
expect(component).toBeTruthy();
});
});
@Component({
selector: 'test-component-wrapper',
template: `<account-lookup filterCurrentAccount="true"
[useAccountIdSearch]="true"
[useCompactResults]="true"
(accountSelected)="null"
placeholder="Find account">
</account-lookup>`,
})
class TestComponentWrapper {
}
當我刪除NgModule它給了我這個錯誤沒有提供NgbModal! –
導入NgbModule.forRoot()或NgbModalModule.forRoot()而不是 – yurzui