jeudi 23 mai 2019

detectChanges resets reactive form. What is a right way to manage form values in tests?

I am writing a test for a reactive form.

app.form.get('name').setValue('new value');
expect(app.form.get('name').value).toEqual('new value');
fixture.detectChanges();
expect(app.form.get('name').value).toEqual('new value'); // <-- Fails.

I debugged it. I see that the control value is resetted to default after detectChanges

What is a right way to manage form values in tests?

Aucun commentaire:

Enregistrer un commentaire