angular - ctor 不是构造函数。Angular7 单元测试
解决方案
在 beforeEach 函数中替换useClass
为useValue
, 内部提供程序。
beforeEach(async(() => {
service = jasmine.createSpyObj('ContactService', ['getContacts']);
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
declarations: [CityComponent],
providers: [{provide: ContactService, useValue: service}]
})
.compileComponents();
}));
推荐阅读
- git - 使用自定义 ssh 密钥从 gitlab 克隆存储库?
- ckeditor - CKEditor 4.13 - 样式(div.xyz)来自哪个核心或插件?
- rally - 具有深度导出的 Rally 自定义列表问题(错误)
- python - 如何在python中创建对象数组
- java - 为什么对象引用的行为不同?
- r - 使用 tidyr::pivot_longer 为列表中的列分配不同的名称,并将它们组合起来
- python - 如何在执行之前从 python 创建 terraform backend.tf 文件以消除插值状态文件问题
- json - 在文本编辑器中使用多种语言
- ios - 以编程方式在拆分视图中启动其他应用程序
- jasmine - 如何在量角器中运行特定的“it”块