【发布时间】:2018-06-19 15:04:43
【问题描述】:
我正在启动一个 Angular 5 项目,它为我的组件和服务自动生成了一些规范单元测试。对于那些需要 Apollo 的组件,我收到错误 NullInjectorError: No provider for Apollo!
我将 Apollo 模块添加到导入和声明部分,如下所示:
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ContractsDashboardComponent, Apollo ]
})
.compileComponents();
}));
但是现在我得到了错误
Failed: Unexpected value 'Apollo' declared by the module 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.
在普通应用程序中,我有一个模块GraphQLModule,它在构造函数中调用apollo.create。我也应该以某种方式嘲笑它吗?
【问题讨论】:
标签: angular unit-testing apollo