From 5c705e800c17237d82bc9065f22e30b720ddcec0 Mon Sep 17 00:00:00 2001 From: Atchyut Pulavarthi Date: Fri, 14 Jun 2024 10:45:14 +0530 Subject: [PATCH] fix(@schematics/angular): update schematics to use RouterModule when --routing flag is present update schematics to use RouterModule instead of RouterTestingModule when generating a new project with the --routing flag Fixes #27691 (cherry picked from commit e3b8b780be72d8a0c6247a25e4e1e1ccfbdea67c) --- .../files/module-files/src/app/app.component.spec.ts.template | 4 ++-- .../e2e/assets/15.0-project/src/app/app.component.spec.ts | 4 ++-- .../18-ssr-project-webpack/src/app/app.component.spec.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/schematics/angular/application/files/module-files/src/app/app.component.spec.ts.template b/packages/schematics/angular/application/files/module-files/src/app/app.component.spec.ts.template index eef727c672ca..c567ade0de2c 100644 --- a/packages/schematics/angular/application/files/module-files/src/app/app.component.spec.ts.template +++ b/packages/schematics/angular/application/files/module-files/src/app/app.component.spec.ts.template @@ -1,12 +1,12 @@ import { TestBed } from '@angular/core/testing';<% if (routing) { %> -import { RouterTestingModule } from '@angular/router/testing';<% } %> +import { RouterModule } from '@angular/router';<% } %> import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({<% if (routing) { %> imports: [ - RouterTestingModule + RouterModule.forRoot([]) ],<% } %> declarations: [ AppComponent diff --git a/tests/legacy-cli/e2e/assets/15.0-project/src/app/app.component.spec.ts b/tests/legacy-cli/e2e/assets/15.0-project/src/app/app.component.spec.ts index b7b4722d8cbc..803558e830fb 100644 --- a/tests/legacy-cli/e2e/assets/15.0-project/src/app/app.component.spec.ts +++ b/tests/legacy-cli/e2e/assets/15.0-project/src/app/app.component.spec.ts @@ -1,12 +1,12 @@ import { TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [ - RouterTestingModule + RouterModule.forRoot([]) ], declarations: [ AppComponent diff --git a/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/src/app/app.component.spec.ts b/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/src/app/app.component.spec.ts index 2f9f07ca654a..4e872828790f 100644 --- a/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/src/app/app.component.spec.ts +++ b/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/src/app/app.component.spec.ts @@ -1,10 +1,10 @@ import { TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; +import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(() => TestBed.configureTestingModule({ - imports: [RouterTestingModule], + imports: [RouterModule.forRoot([])], declarations: [AppComponent] }));