我有几个失败的测试只输出[object ErrorEvent] thrown.我在控制台中看不到任何可以帮助我查明违规代码的内容.我需要做些什么来追踪这些?
[编辑]:我正在运行Karma v1.70,Jasmine v2.7.0
我试图迭代我的组件中的formArray但我得到以下错误
Error: Cannot find control with unspecified name attribute
这是我的类文件中的逻辑
export class AreasFormComponent implements OnInit {
public initialState: any;
public areasForm: FormGroup;
constructor(private fb: FormBuilder) { }
private area(): any {
return this.fb.group({
name: ['', [Validators.required]],
latLong: ['', [Validators.required]],
details: ['', [Validators.required]]
});
}
public ngOnInit(): void {
this.areasForm = this.fb.group({
name: ['', [Validators.required]],
areas: this.fb.array([this.area()])
});
}
}
Run Code Online (Sandbox Code Playgroud)
和我的模板文件
<form class="areas-form" [formGroup]="areasForm" (ngSubmit)="onSubmit(areasForm.values)">
<md-input-container class="full-width">
<input mdInput placeholder="Location Name" type="text" formControlName="name" required>
<md-error *ngIf="areasForm.get('name').hasError('required')">Please enter the locationName</md-error>
</md-input-container>
<md-grid-list …Run Code Online (Sandbox Code Playgroud)