Angular · Middle · Question 49 of 75
Why call fixture.detectChanges() in a component test?
- ✓Correct answer: To run change detection so the template reflects the component state (and
ngOnInitruns the first time) - 2To compile the TypeScript code of the test
- 3To reset the component between tests
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.