【发布时间】:2018-07-01 15:32:51
【问题描述】:
我刚刚使用带有菜单的模板创建了一个带有 Ionic cli 的应用程序。
我已经设置了所有的测试配置。我的 TestBed 是这样的
TestBed.configureTestingModule({
declarations: [MyApp],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
],
providers: [
{ provide: StatusBar, useFactory: () => StatusBarMock.instance() },
{ provide: SplashScreen, useFactory: () => SplashScreenMock.instance() },
],
});
模拟来自ionic-mocks
import { StatusBarMock, SplashScreenMock } from 'ionic-mocks';
我的测试通过了
beforeEach(() => {
fixture = TestBed.createComponent(MyApp);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('component is created', () => {
expect(component).toBeTruthy();
});
但我收到了这个“警告”:
错误:'未处理的承诺拒绝:','未找到主页的组件工厂。你把它添加到@NgModule.entryComponents 了吗?',
HomePage 位于 MyApp 的 @NgModule 上 entryComponents。我是否也必须将它包含在 TestBed 中?怎么样?
【问题讨论】:
标签: angular unit-testing ionic-framework