angular - 如何避免对默认“应该创建”方法的 api 调用
问题描述
当我使用 Angular cli 创建组件时,ng-cli 会为我生成一些默认测试。但是这个测试在我的詹金斯身上间歇性地失败了。
以下是更多细节:
例子.component.ts
ngOnit(){
this.get1stData();
this.get2ndData();
}
get1stData(){
this.service.get1stData().subscribe()....
}
get2ndData(){
this.service.get2ndData().subscribe()....
}
example.component.spec.ts
beforeEach(() => {
fixture = TestBed.createComponent(NamespaceHomeComponent);
component = fixture.componentInstance;
service = TestBed.get(service);
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
如果 api 有问题,这个简单的测试会失败。我怎样才能避免在这里调用 api。
我收到此错误:
{
"message": "An error was thrown in afterAll\nUncaught [object Object] thrown",
"str": "An error was thrown in afterAll\nUncaught [object Object] thrown"
}
解决方案
推荐阅读
- c# - Office 365 EWS-GetUserAvailability ID 为空
- dotnetnuke - 安装 2sic_2SexyContent_10.25.02_Install.zip 时出错
- sql-server - 将行与sql server中同一表中的其他行进行比较
- javascript - 防止 ajax 返回的 javascript 立即执行
- reactjs - TypeError: (0, _reactNavigation.default) 不是函数。反应原生
- ios - 在 Objective C 中执行代码之前等待分配一个变量
- azure - 使用 powershell 将 Azure sql 数据库导出到 blob 存储时出错
- python-2.7 - Python 2.7.17 错误:SyntaxError:非默认参数遵循默认参数
- python - 如何根据多个条件将值插入数据框?逻辑问题
- node.js - 通过 AWS Lambda 将 JSON 有效负载发送到 Slack