From 4d75117b3b089cf0dc07da32080ee87b04c3ad1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=ABSergei?= Date: Thu, 21 May 2026 14:48:05 +0300 Subject: [PATCH] feat(cli): pass skip testing flag to application schematic Refs #2575 --- actions/new.action.ts | 4 ++-- test/actions/new.action.spec.ts | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/actions/new.action.ts b/actions/new.action.ts index 0c1dee807..2d0dd1e15 100644 --- a/actions/new.action.ts +++ b/actions/new.action.ts @@ -88,13 +88,13 @@ const mapContextToSchematicOptions = ( if (context.directory !== undefined) options.push(new SchematicOption('directory', context.directory)); - if (context.dryRun) - options.push(new SchematicOption('dry-run', true)); + if (context.dryRun) options.push(new SchematicOption('dry-run', true)); options.push(new SchematicOption('skip-git', context.skipGit)); options.push(new SchematicOption('strict', context.strict)); if (context.skipTests) { options.push(new SchematicOption('spec', false)); + options.push(new SchematicOption('skipTesting', true)); } if (context.packageManager !== undefined) diff --git a/test/actions/new.action.spec.ts b/test/actions/new.action.spec.ts index 5be6d7fc9..49ea13685 100644 --- a/test/actions/new.action.spec.ts +++ b/test/actions/new.action.spec.ts @@ -72,7 +72,9 @@ describe('NewAction', () => { process.exit = originalExit; }); - const baseContext = (overrides: Partial = {}): NewCommandContext => ({ + const baseContext = ( + overrides: Partial = {}, + ): NewCommandContext => ({ name: 'test-project', directory: undefined, dryRun: false, @@ -102,6 +104,19 @@ describe('NewAction', () => { expect(specOption).toBeDefined(); }); + it('should pass --skipTesting=true to schematics when --skip-tests is true', async () => { + const context = baseContext({ skipTests: true }); + await action.handle(context); + + expect(mockExecute).toHaveBeenCalledTimes(1); + const [, schematicOptions] = mockExecute.mock.calls[0]; + + const skipTestingOption = schematicOptions.find( + (opt: SchematicOption) => opt.toCommandString() === '--skip-testing', + ); + expect(skipTestingOption).toBeDefined(); + }); + it('should not pass spec option to schematics when --skip-tests is false', async () => { const context = baseContext({ skipTests: false }); await action.handle(context); @@ -123,9 +138,8 @@ describe('NewAction', () => { const [, schematicOptions] = mockExecute.mock.calls[0]; - const skipTestsOption = schematicOptions.find( - (opt: SchematicOption) => - opt.toCommandString().includes('skip-tests'), + const skipTestsOption = schematicOptions.find((opt: SchematicOption) => + opt.toCommandString().includes('skip-tests'), ); expect(skipTestsOption).toBeUndefined(); });