angular/packages/core/schematics/migrations/router-testing-module-migration
Alan Agius 26fed34e0e
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
..
BUILD.bazel refactor(compiler-cli): Remove deep imports of compiler-cli in angular/core 2025-10-28 15:58:56 +01:00
index.ts refactor(compiler-cli): Remove deep imports of compiler-cli in angular/core 2025-10-28 15:58:56 +01:00
migration.ts
README.md build: format md files 2025-11-06 10:03:05 -08:00
schema.json
types.ts
utils.ts

RouterTestingModule Migration

This migration automatically converts deprecated RouterTestingModule usages to the recommended modern APIs.

What it does

  • Replaces RouterTestingModule.withRoutes([...]) with RouterModule.forRoot([...]) for NgModule tests
  • Replaces RouterTestingModule with RouterModule.forRoot([]) when no routes are provided
  • For standalone tests (detected by presence of providers), moves to provideRouter([...]) instead
  • Updates import statements to use @angular/router instead of @angular/router/testing
  • Preserves other imports and test configuration

Files

  • router_testing_module_migration.ts - Main migration logic using TsurgeFunnelMigration
  • index.ts - Entry point for the schematic
  • ../../test/router_testing_to_provide_router_spec.ts - Comprehensive test suite
  • MIGRATION_NOTES.md - Detailed documentation with examples
  • BUILD.bazel - Bazel build configuration

Running the migration

The migration runs automatically as part of ng update @angular/core for v21.0.0+.

To run manually:

ng update @angular/core --migrate-only router-testing-to-provide-router