<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/testing-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz" -->

---
title: Testing Angular routing components with...
description: A guide to writing integrated routing component tests in Angular using modern standalone APIs. Covers RouterTestingHarness (Angular 15.2), provideRouter...
canonical: https://daily.dev/posts/testing-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Testing Angular routing components with RouterTestingHarness, provideLocationMocks, and provideRouter | daily.dev
og:description: A guide to writing integrated routing component tests in Angular using modern standalone APIs. Covers RouterTestingHarness (Angular 15.2), provideRouter...
og:url: https://daily.dev/posts/testing-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz
og:image: https://api.daily.dev/og/posts/2cvPXirwz.png
og:image:alt: Testing Angular routing components with RouterTestingHarness, provideLocationMocks, and provideRouter
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 Angular routing components with RouterTestingHarness, provideLocationMocks, and provideRouter

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

## Summary

A guide to writing integrated routing component tests in Angular using modern standalone APIs. Covers RouterTestingHarness (Angular 15.2), provideRouter (Angular 14.2), and provideLocationMocks (Angular 15.0) as replacements for the older RouterTestingModule.withRoutes pattern. Includes a full working example testing the DashboardComponent from the Tour of Heroes tutorial, demonstrating how to set up the test module, navigate with RouterTestingHarness.navigateByUrl, and assert on location changes after user interactions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://playfulprogramming.com/posts/testing-angular-routing-components-with-routertestingharness-providelocationmocks-and-providerouter-oi8>

## Similar posts on daily.dev

- [Routing for beginners](https://daily.dev/posts/routing-for-beginners-qghjsoei4) · Angular.love · 1 upvotes · 0 comments
- [Component Harness: Writing Tests That Survive Refactors](https://daily.dev/posts/component-harness-writing-tests-that-survive-refactors-bsljztomx) · Angular.love · 0 upvotes · 1 comments
- [Angular 00: Introduction to Angular 22](https://daily.dev/posts/angular-00-introduction-to-angular-22-xtjsurcuc) · Medium · 3 upvotes · 0 comments
- [Angular 22: The Evolution of Modern Angular](https://daily.dev/posts/angular-22-the-evolution-of-modern-angular-tpdetu6wa) · Telerik · 0 upvotes · 0 comments
- [How To Use Query Parameters with Angular Router](https://daily.dev/posts/how-to-use-query-parameters-with-angular-router-uniqwnjiy) · DigitalOcean Community · 1 upvotes · 1 comments

---

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-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz)

```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 Angular routing components with RouterTestingHarness, provideLocationMocks, and provideRouter","url":"https://daily.dev/posts/testing-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/testing-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz"},"datePublished":"2026-03-16T21:46:58.487Z","dateModified":"2026-03-17T18:02:25.750Z","description":"A guide to writing integrated routing component tests in Angular using modern standalone APIs. Covers RouterTestingHarness (Angular 15.2), provideRouter...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a68020b98f3259aae1279e85b95400a0?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/a68020b98f3259aae1279e85b95400a0?_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-angular-routing-components-with-routertestingharness-providelocationmocks-and-provideroute-2cvpxirwz","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,typescript,angular","timeRequired":"PT4M"}
{"@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 Angular routing components with RouterTestingHarness, provideLocationMocks, and provideRouter"}]}
```

