A deep dive into testing Angular routing components using RouterTestingModule. Covers how the Angular Location service and its dependencies abstract browser APIs, why RouterTestingModule replaces Location with SpyLocation, and how to write both shallow and integrated routing component tests for the DashboardComponent from the Tour of Heroes tutorial. Includes full code examples for fake router link directives, test setup with fakeAsync, and asserting navigation via router spies or Location#path.
Table of contents
Angular's RouterTestingModule Copy link Link copied!Shallow routing component test Copy link Link copied!Integrated routing component test with the RouterTestingModule Copy link Link copied!Conclusion Copy link Link copied!Thank you Copy link Link copied!Related articles Copy link Link copied!Reviewers Copy link Link copied!Sort: