Performance: Testing routing and navigation
MEDIUM IMPACT
This affects the speed and responsiveness of page navigation and route changes in an Angular app.
it('should navigate to home', async () => { await router.navigate(['/home']); fixture.detectChanges(); expect(location.path()).toBe('/home'); });
it('should navigate to home', () => { router.navigate(['/home']); fixture.detectChanges(); expect(location.path()).toBe('/home'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Immediate detectChanges after navigate | Multiple DOM updates | Multiple reflows | High paint cost | [X] Bad |
| Await navigation before detectChanges | Single DOM update | Single reflow | Lower paint cost | [OK] Good |