我有一個小Angular v4.x使用Angluar Material 2.x 它有一個模式(使用MdDialog)登錄組件 - 幾乎沒有別的。 我所有的測試都是失敗:Angular 4.x中的錯誤Karma測試「沒有Provider for FocusTrapFactory」
失敗:無提供FocusTrapFactory!在injectionError (http://localhost:9876/base/src/test.ts?31c6eb17e2414560f8e07e35e9c56bebb408ba58:2074:86) [角] 在noProviderError(http://localhost:9876/base/src/test.ts?31c6eb17e2414560f8e07e35e9c56bebb408ba58:2112:12) [角] ...
我login.component.spec.ts是
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MdDialog, MdDialogContainer, MdInputContainer, OVERLAY_PROVIDERS } from '@angular/material';
import { HttpModule } from '@angular/http';
import { AuthenticationService } from '../shared/servicesIndex';
import { LoginComponent } from './login.component';
describe('LoginComponent',() => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.overrideModule(BrowserDynamicTestingModule, {
set: {
entryComponents: [MdDialogContainer]
}
});
TestBed.configureTestingModule(
{
imports: [
FormsModule,
RouterTestingModule,
HttpModule,
NoopAnimationsModule
],
declarations: [
LoginComponent,
MdInputContainer,
MdDialogContainer
],
providers: [
MdDialog,
OVERLAY_PROVIDERS,
AuthenticationService
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create',() => {
expect(component).toBeTruthy();
});
});
邏輯告訴我進口FocusTrapFactory並將其添加到我的提供商列表 - 但我找不到它來導入它!
我不知所措。我的Google-fu是fu。