Skip to content

Commit

Permalink
feat(node): Added E2E project generation option to NestJs app generator
Browse files Browse the repository at this point in the history
  • Loading branch information
FurlanLuka committed Feb 5, 2023
1 parent f38268b commit 4a581da
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
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

0 comments on commit 4a581da

Please sign in to comment.