<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l" -->

---
title: Testing routed Angular components with the...
description: A detailed guide on testing routed Angular components using two approaches: shallow tests with an ActivatedRouteStub and integrated tests with...
canonical: https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Testing routed Angular components with the RouterTestingModule | daily.dev
og:description: A detailed guide on testing routed Angular components using two approaches: shallow tests with an ActivatedRouteStub and integrated tests with...
og:url: https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l
og:image: https://api.daily.dev/og/posts/r5YQ6gr5L.png
og:image:alt: Testing routed Angular components with the RouterTestingModule
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Testing routed Angular components with the RouterTestingModule

**[Playful Programming](https://daily.dev/sources/playfulprogramming)** · [@layzeedk](https://daily.dev/layzeedk) · 18 min read · 0 upvotes · 0 comments

## Summary

A detailed guide on testing routed Angular components using two approaches: shallow tests with an ActivatedRouteStub and integrated tests with RouterTestingModule. Uses the HeroDetailComponent from the Tour of Heroes tutorial as a case study. Covers setting up ActivatedRouteStub to simulate route parameters, configuring TestBed with fake services, and using RouterTestingModule.withRoutes() with a TestRootComponent containing a router outlet for integrated tests. Includes full code listings for both test suites.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://playfulprogramming.com/posts/testing-routed-angular-components-with-the-routertestingmodule-1791>

---

Tags: [#testing](https://daily.dev/tags/testing), [#typescript](https://daily.dev/tags/typescript), [#angular](https://daily.dev/tags/angular)

[View this post on daily.dev](https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Testing routed Angular components with the RouterTestingModule","url":"https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l"},"datePublished":"2026-03-16T21:46:32.764Z","dateModified":"2026-03-17T18:01:29.318Z","description":"A detailed guide on testing routed Angular components using two approaches: shallow tests with an ActivatedRouteStub and integrated tests with...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9f9557c3810bad0c9d4c6632342eb717?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9f9557c3810bad0c9d4c6632342eb717?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Playful Programming","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Lars Gyrup Brink Nielsen","url":"https://daily.dev/layzeedk","image":"https://avatars1.githubusercontent.com/u/6364586?v=4","description":"Tech Writer, Tech Speaker, FOSS Maintainer, Microsoft MVP.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":410}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/testing-routed-angular-components-with-the-routertestingmodule-r5yq6gr5l","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,typescript,angular","timeRequired":"PT18M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Playful Programming","item":"https://daily.dev/sources/playfulprogramming"},{"@type":"ListItem","position":3,"name":"Testing routed Angular components with the RouterTestingModule"}]}
```

