In a Jasmine/Karma test of a component at an Angular 7 application you may want to do this:
tick();
fixture.detectChanges();
This comes into play when you want the component to do something asynchronously which you will fake out with some mocking so there won't really be much of a time delay but nonetheless it is all still happening asynchronously. So when would you just do this alone?
fixture.detectChanges();
The time for that is when you are still triggering an act that effects the DOM, perhaps by setting a flag that will unhide something in an *ngIf or such, and you need to react to the updated DOM.
No comments:
Post a Comment