Bac*_*tnz 5 forms unit-testing angular
模板HTML:
<form
#myForm="ngForm"
novalidate>
<input
#myCtrl
required
type="input"
name="myCtrl"
id="myCtrl"
[(ngModel)]="value">
</form>
Run Code Online (Sandbox Code Playgroud)
组件有:
@ViewChild('myForm') myForm: NgForm;
Run Code Online (Sandbox Code Playgroud)
在我的测试中,当我在console.log中进行以下操作时,我得到{}
fixture.debugElement.componentInstance.myForm.controls
Run Code Online (Sandbox Code Playgroud)
尽管表单应包含无效的FormControl errors: null,status 'VALID'但表单也有.使用ViewChild而不是FormBuilder配置测试表单是否可能?有没有办法用我的ViewChild设置呢?