From fb5250851b8b6e1adb7d29bbc4c1a02244d10e5d Mon Sep 17 00:00:00 2001 From: Marc Sensenich Date: Thu, 9 Jun 2016 20:55:00 -0400 Subject: [PATCH] feat(e2e): Added --config flag to e2e command Allow for a user to use the optional --config flag to specify the usage of a different configuration file for Protractor end-to-end testing. This configuration file is first defined in angular-cli.json and refrenced by the key defined --- packages/angular-cli/commands/e2e.ts | 7 +++++-- packages/angular-cli/tasks/e2e.ts | 8 ++++++-- tests/e2e/tests/test/e2e.ts | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/angular-cli/commands/e2e.ts b/packages/angular-cli/commands/e2e.ts index c3074afb649d..c12773b11847 100644 --- a/packages/angular-cli/commands/e2e.ts +++ b/packages/angular-cli/commands/e2e.ts @@ -6,7 +6,10 @@ const E2eCommand = Command.extend({ name: 'e2e', description: 'Run e2e tests in existing project', works: 'insideProject', - run: function () { + availableOptions: [ + { name: 'config', type: String, aliases: ['c', 'cf'] }, + ], + run: function (commandOptions: any) { this.project.ngConfig = this.project.ngConfig || CliConfig.fromProject(); const e2eTask = new E2eTask({ @@ -15,7 +18,7 @@ const E2eCommand = Command.extend({ project: this.project }); - return e2eTask.run(); + return e2eTask.run(commandOptions); } }); diff --git a/packages/angular-cli/tasks/e2e.ts b/packages/angular-cli/tasks/e2e.ts index 4de5cbac8fc7..e33de56711e3 100644 --- a/packages/angular-cli/tasks/e2e.ts +++ b/packages/angular-cli/tasks/e2e.ts @@ -4,12 +4,16 @@ import {exec} from 'child_process'; export const E2eTask = Task.extend({ - run: function () { + run: function (options: any) { const ui = this.ui; let exitCode = 0; + let protractorConfig = (options.config) ? + this.project.ngConfig.config.e2e.protractor[options.config] : + this.project.ngConfig.config.e2e.protractor.config; + return new Promise((resolve) => { - exec(`npm run e2e -- ${this.project.ngConfig.config.e2e.protractor.config}`, + exec(`npm run e2e -- ${protractorConfig}`, (err: NodeJS.ErrnoException, stdout: string, stderr: string) => { ui.writeLine(stdout); if (err) { diff --git a/tests/e2e/tests/test/e2e.ts b/tests/e2e/tests/test/e2e.ts index ca66091906c7..3ae7cc961039 100644 --- a/tests/e2e/tests/test/e2e.ts +++ b/tests/e2e/tests/test/e2e.ts @@ -19,5 +19,6 @@ export default function() { .then(() => _runServeAndE2e()) .then(() => _runServeAndE2e('--prod')) .then(() => _runServeAndE2e('--aot')) - .then(() => _runServeAndE2e('--aot', '--prod')); + .then(() => _runServeAndE2e('--aot', '--prod')) + .then(() => _runServeAndE2e('--config', 'config')); }