Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): Added E2E project generation option to NestJs app generator #14805

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/generated/packages/nest/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions packages/nest/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down Expand Up @@ -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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function normalizeOptions(
appProjectRoot,
linter: options.linter ?? Linter.EsLint,
unitTestRunner: options.unitTestRunner ?? 'jest',
e2eTestRunner: options.e2eTestRunner ?? 'jest',
};
}

Expand All @@ -42,6 +43,7 @@ export function toNodeApplicationGeneratorOptions(
standaloneConfig: options.standaloneConfig,
tags: options.tags,
unitTestRunner: options.unitTestRunner,
e2eTestRunner: options.e2eTestRunner,
setParserOptionsProject: options.setParserOptionsProject,
bundler: 'webpack', // Some features require webpack plugins such as TS transformers
};
Expand Down
4 changes: 2 additions & 2 deletions packages/nest/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Linter } from '@nrwl/linter';
import { UnitTestRunner } from '../../utils/test-runners';

export interface ApplicationGeneratorOptions {
name: string;
Expand All @@ -10,7 +9,8 @@ export interface ApplicationGeneratorOptions {
skipPackageJson?: boolean;
standaloneConfig?: boolean;
tags?: string;
unitTestRunner?: UnitTestRunner;
unitTestRunner?: 'jest' | 'none';
e2eTestRunner?: 'jest' | 'none';
setParserOptionsProject?: boolean;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/nest/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down