diff --git a/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap index 5dec4b35d7de0..ecb84bd59c4c5 100644 --- a/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/angular/src/generators/application/__snapshots__/application.spec.ts.snap @@ -128,7 +128,6 @@ exports[`app --minimal should skip "nx-welcome.component.ts" file and references import { RouterModule } from '@angular/router'; @Component({ - standalone: true, imports: [RouterModule], selector: 'app-root', templateUrl: './app.component.html', @@ -172,7 +171,6 @@ exports[`app --minimal should skip "nx-welcome.component.ts" file and references "import { Component } from '@angular/core'; @Component({ - standalone: true, imports: [], selector: 'app-root', templateUrl: './app.component.html', @@ -245,7 +243,6 @@ import { RouterModule } from '@angular/router'; import { NxWelcomeComponent } from './nx-welcome.component'; @Component({ - standalone: true, imports: [NxWelcomeComponent, RouterModule], selector: 'app-root', templateUrl: './app.component.html', @@ -313,7 +310,6 @@ exports[`app --standalone should generate a standalone app correctly without rou import { NxWelcomeComponent } from './nx-welcome.component'; @Component({ - standalone: true, imports: [NxWelcomeComponent, ], selector: 'app-root', templateUrl: './app.component.html', diff --git a/packages/angular/src/generators/application/application.spec.ts b/packages/angular/src/generators/application/application.spec.ts index 6d43ba52aaa72..5cb2799476391 100644 --- a/packages/angular/src/generators/application/application.spec.ts +++ b/packages/angular/src/generators/application/application.spec.ts @@ -500,9 +500,14 @@ describe('app', () => { it('should create Nx specific `nx-welcome.component.ts` file', async () => { await generateApp(appTree, 'my-dir/my-app'); - expect( - appTree.read('my-dir/my-app/src/app/nx-welcome.component.ts', 'utf-8') - ).toContain('Hello there'); + + const nxWelcomeComponentText = appTree.read( + 'my-dir/my-app/src/app/nx-welcome.component.ts', + 'utf-8' + ); + expect(nxWelcomeComponentText).not.toContain('standalone: true'); + expect(nxWelcomeComponentText).toContain('standalone: false'); + expect(nxWelcomeComponentText).toContain('Hello there'); }); it('should update the AppComponent spec to target Nx content', async () => { @@ -1008,9 +1013,12 @@ describe('app', () => { appTree.read('standalone/src/app/app.component.spec.ts', 'utf-8') ).toMatchSnapshot(); expect(appTree.exists('standalone/src/app/app.module.ts')).toBeFalsy(); - expect( - appTree.read('standalone/src/app/nx-welcome.component.ts', 'utf-8') - ).toContain('standalone: true'); + const nxWelcomeComponentText = appTree.read( + 'standalone/src/app/nx-welcome.component.ts', + 'utf-8' + ); + expect(nxWelcomeComponentText).not.toContain('standalone: true'); + expect(nxWelcomeComponentText).not.toContain('standalone: false'); }); it('should generate a standalone app correctly without routing', async () => { @@ -1032,9 +1040,12 @@ describe('app', () => { appTree.read('standalone/src/app/app.component.spec.ts', 'utf-8') ).toMatchSnapshot(); expect(appTree.exists('standalone/src/app/app.module.ts')).toBeFalsy(); - expect( - appTree.read('standalone/src/app/nx-welcome.component.ts', 'utf-8') - ).toContain('standalone: true'); + const nxWelcomeComponentText = appTree.read( + 'standalone/src/app/nx-welcome.component.ts', + 'utf-8' + ); + expect(nxWelcomeComponentText).not.toContain('standalone: true'); + expect(nxWelcomeComponentText).not.toContain('standalone: false'); }); it('should should not use event coalescing in versions lower than v18', async () => { diff --git a/packages/angular/src/generators/application/files/nx-welcome/claimed/standalone/src/app/nx-welcome.component.ts__tpl__ b/packages/angular/src/generators/application/files/nx-welcome/claimed/standalone/src/app/nx-welcome.component.ts__tpl__ index 05fcc951466fc..dadb9f350d568 100644 --- a/packages/angular/src/generators/application/files/nx-welcome/claimed/standalone/src/app/nx-welcome.component.ts__tpl__ +++ b/packages/angular/src/generators/application/files/nx-welcome/claimed/standalone/src/app/nx-welcome.component.ts__tpl__ @@ -2,8 +2,8 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { CommonModule } from '@angular/common'; @Component({ - selector: '<%= nxWelcomeSelector %>', - standalone: true, + selector: '<%= nxWelcomeSelector %>',<% if (setStandaloneTrue) { %> + standalone: true,<% } %> imports: [CommonModule], template: `