Всем привет :)
Нужна помощь с юнит тестингом директиви FormGroupDirective
Примерная реализация здесь
https://medium.com/@amcdnl/reactive-angular-forms-with-ngrx-533a2f28c127Я пробую тестить внутри тестового компонента:
@Component({
selector: "test-component",
template:
`
<form [formGroup]="form" formConnect>
</form>
`
})
class TestComponent {
form: FormGroup;
constructor(
private formBuilder: FormBuilder
) {
this.initializeLdapConfigurationForm();
}
private form(): void {
this.form =
this.formBuilder.group({
name: ["", [Validators.required, Validators.maxLength(NAME_MAX_LENGTH)]],
...
});
}
}
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
FormConnectDirective,
TestComponent
],
providers: [
FormBuilder,
FormGroupDirective
],
}).compileComponents();
fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
});
но похоже внутри тестової директиви нет доступа к форме ...
Cannot read property 'patchValue' of null thrown
Есть ли у кого-то опыт с тестированием такой директивы?