最简单的test case里用css class也检索不到这个continue按钮:
打印为null:
加上两行代码:
component.mode.controls['deliveryModeId'].setValue(null);
fixture.detectChanges();
果然,这次就能检索到按钮了:
这说明上述两行代码一定有一行起了作用。
把第一行代码注释掉,只剩fixture.detectChanges()也能检索到:
加了spy语句还是不行:
注释掉fixture.detectChanges()后,button为null:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":