Angular · Middle · Question 49 of 75

Why call fixture.detectChanges() in a component test?

Explanation

After changing component state in a test, you update the DOM with detectChanges() (or await fixture.whenStable()), then query elements via fixture.nativeElement or debugElement.

Further reading

Problem with a question

Angular · Middle · question 49

Test yourself

Take the Angular · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz