Skip to content

Commit 1f3e276

Browse files
nlm-proalexeagle
authored andcommitted
fix(@schematics/angular): --minimal should prevent generating e2e (#12742)
* fix(@schematics/angular): --minimal should prevent generating e2e Don't run the e2e schematic when using application or ng-new schematics with option.minimal set to true. fix #12739 * style: inverse logic according to feedback * test(@schematics/angular): app and ng-new --minimal shouldn't generate e2e
1 parent 258df04 commit 1f3e276

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

packages/schematics/angular/application/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export default function (options: ApplicationOptions): Rule {
372372
}),
373373
move(sourceDir),
374374
]), MergeStrategy.Overwrite),
375-
schematic('e2e', e2eOptions),
375+
options.minimal ? noop() : schematic('e2e', e2eOptions),
376376
options.skipPackageJson ? noop() : addDependenciesToPackageJson(options),
377377
]);
378378
};

packages/schematics/angular/application/index_spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ describe('Application Schematic', () => {
136136
expect(content.rules['component-selector'][2]).toMatch('app');
137137
});
138138

139+
it('minimal=true should not create e2e project', () => {
140+
const options = { ...defaultOptions, minimal: true };
141+
142+
const tree = schematicRunner.runSchematic('application', options, workspaceTree);
143+
const files = tree.files;
144+
expect(files.indexOf('/projects/foo-e2e')).toEqual(-1);
145+
const confContent = JSON.parse(tree.readContent('/angular.json'));
146+
expect(confContent.projects['foo-e2e']).toBeUndefined();
147+
});
148+
139149
describe(`update package.json`, () => {
140150
it(`should add build-angular to devDependencies`, () => {
141151
const tree = schematicRunner.runSchematic('application', defaultOptions, workspaceTree);

packages/schematics/angular/ng-new/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default function (options: NgNewOptions): Rule {
5757
skipPackageJson: false,
5858
// always 'skipInstall' here, so that we do it after the move
5959
skipInstall: true,
60+
minimal: options.minimal,
6061
};
6162

6263
return chain([

packages/schematics/angular/ng-new/index_spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,14 @@ describe('Ng New Schematic', () => {
6565
expect(files.indexOf('/bar/angular.json')).toBeGreaterThanOrEqual(0);
6666
expect(files.indexOf('/bar/src')).toBe(-1);
6767
});
68+
69+
it('minimal=true should not create e2e project', () => {
70+
const options = { ...defaultOptions, minimal: true };
71+
72+
const tree = schematicRunner.runSchematic('ng-new', options);
73+
const files = tree.files;
74+
expect(files.indexOf('/bar/e2e')).toEqual(-1);
75+
const confContent = JSON.parse(tree.readContent('/bar/angular.json'));
76+
expect(confContent.projects['foo-e2e']).toBeUndefined();
77+
});
6878
});

0 commit comments

Comments
 (0)