【发布时间】:2022-01-10 00:17:52
【问题描述】:
我在角度分量中的一个函数中有以下两行。我的角度测试失败,抛出错误 TypeError: Cannot set properties of null (setting 'value')。
test.ts
function reset(){
(<HTMLInputElement>document.getElementById('test1')).value = '';
this.nameCtrl.setValue(null);
}
test.spec
fixture.debugElement.componentInstance.test1.value='';
fixture.debugElement.componentInstance.nameCtrl.setValue(null);
我尝试使用上面的方法来模拟静止的线条,但它仍然失败。请帮忙
【问题讨论】:
-
我不明白 test.ts 和 test.spec 有什么关系。组件在哪里?你有
orgTeam实例化吗?
标签: angular angular-test