diff --git a/docs/generated/packages/nest/generators/application.json b/docs/generated/packages/nest/generators/application.json index 80d801d23cb14..6350158831da0 100644 --- a/docs/generated/packages/nest/generators/application.json +++ b/docs/generated/packages/nest/generators/application.json @@ -43,6 +43,12 @@ "enum": ["jest", "none"], "default": "jest" }, + "e2eTestRunner": { + "type": "string", + "enum": ["jest", "none"], + "description": "Test runner to use for end to end (e2e) tests", + "default": "jest" + }, "tags": { "description": "Add tags to the application (used for linting).", "type": "string" diff --git a/packages/nest/src/generators/application/application.spec.ts b/packages/nest/src/generators/application/application.spec.ts index d8040b1e97e5b..af3f8556dd4bf 100644 --- a/packages/nest/src/generators/application/application.spec.ts +++ b/packages/nest/src/generators/application/application.spec.ts @@ -13,6 +13,15 @@ describe('application generator', () => { jest.clearAllMocks(); }); + it('should generate project configurations', async () => { + await applicationGenerator(tree, { name: appName }); + + const projectConfigurations = devkit.getProjects(tree); + + expect(projectConfigurations.get(appDirectory)).toBeTruthy(); + expect(projectConfigurations.get(`${appDirectory}-e2e`)).toBeTruthy(); + }); + it('should generate files', async () => { await applicationGenerator(tree, { name: appName }); @@ -67,4 +76,17 @@ describe('application generator', () => { expect(devkit.formatFiles).not.toHaveBeenCalled(); }); }); + + describe('--e2e-test-runner none', () => { + it('should not generate e2e test project', async () => { + await applicationGenerator(tree, { + name: appName, + e2eTestRunner: 'none', + }); + + const projectConfigurations = devkit.getProjects(tree); + + expect(projectConfigurations.get(`${appDirectory}-e2e`)).toBeUndefined(); + }); + }); }); diff --git a/packages/nest/src/generators/application/lib/normalize-options.ts b/packages/nest/src/generators/application/lib/normalize-options.ts index a2678b6e67bc8..8891dabb3103d 100644 --- a/packages/nest/src/generators/application/lib/normalize-options.ts +++ b/packages/nest/src/generators/application/lib/normalize-options.ts @@ -28,6 +28,7 @@ export function normalizeOptions( appProjectRoot, linter: options.linter ?? Linter.EsLint, unitTestRunner: options.unitTestRunner ?? 'jest', + e2eTestRunner: options.e2eTestRunner ?? 'jest', }; } @@ -44,6 +45,7 @@ export function toNodeApplicationGeneratorOptions( standaloneConfig: options.standaloneConfig, tags: options.tags, unitTestRunner: options.unitTestRunner, + e2eTestRunner: options.e2eTestRunner, setParserOptionsProject: options.setParserOptionsProject, rootProject: options.rootProject, bundler: 'webpack', // Some features require webpack plugins such as TS transformers diff --git a/packages/nest/src/generators/application/schema.d.ts b/packages/nest/src/generators/application/schema.d.ts index e71c288ef78c6..f45728a1e0a7f 100644 --- a/packages/nest/src/generators/application/schema.d.ts +++ b/packages/nest/src/generators/application/schema.d.ts @@ -1,5 +1,4 @@ import { Linter } from '@nrwl/linter'; -import { UnitTestRunner } from '../../utils/test-runners'; export interface ApplicationGeneratorOptions { name: string; @@ -10,7 +9,8 @@ export interface ApplicationGeneratorOptions { skipPackageJson?: boolean; standaloneConfig?: boolean; tags?: string; - unitTestRunner?: UnitTestRunner; + unitTestRunner?: 'jest' | 'none'; + e2eTestRunner?: 'jest' | 'none'; setParserOptionsProject?: boolean; rootProject?: boolean; } diff --git a/packages/nest/src/generators/application/schema.json b/packages/nest/src/generators/application/schema.json index 8ffee1cb50270..3acc26f63f81d 100644 --- a/packages/nest/src/generators/application/schema.json +++ b/packages/nest/src/generators/application/schema.json @@ -43,6 +43,12 @@ "enum": ["jest", "none"], "default": "jest" }, + "e2eTestRunner": { + "type": "string", + "enum": ["jest", "none"], + "description": "Test runner to use for end to end (e2e) tests", + "default": "jest" + }, "tags": { "description": "Add tags to the application (used for linting).", "type": "string"