Skip to content

Commit

Permalink
feat(@angular/cli): override suite in the protractor config
Browse files Browse the repository at this point in the history
resolves: 807
Override suite in the protractor config.
Can send in multiple suite by comma seperated values (ng e2e --suite=suite1.ts, suite2.ts).

Issue link
 github.com/angular/issues/807
 github.com/angular/pull/3551
  • Loading branch information
aniruddhadas9 authored and filipesilva committed Jan 3, 2018
1 parent f776d3c commit 265eb96
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docs/documentation/e2e.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ Please note that options that are supported by `ng serve` are also supported by
</p>
</details>

<details>
<summary>suite</summary>
<p>
<code>--suite</code> (aliases: <code>-su</code>)
</p>
<p>
Override suite in the protractor config. Can send in multiple suite by comma separated values (<code>ng e2e --suite=suiteA,suiteB</code>).
</p>
</details>

<details>
<summary>webdriver-update</summary>
<p>
Expand Down
10 changes: 10 additions & 0 deletions packages/@angular/cli/commands/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface E2eTaskOptions extends ServeTaskOptions {
serve: boolean;
webdriverUpdate: boolean;
specs: string[];
suite: string;
elementExplorer: boolean;
}

Expand Down Expand Up @@ -42,6 +43,15 @@ const E2eCommand = Command.extend({
Can send in multiple specs by repeating flag (ng e2e --specs=spec1.ts --specs=spec2.ts).
`
},
{
name: 'suite',
type: String,
aliases: ['su'],
description: oneLine`
Override suite in the protractor config.
Can send in multiple suite by comma separated values (ng e2e --suite=suiteA,suiteB).
`
},
{
name: 'element-explorer',
type: Boolean,
Expand Down
4 changes: 4 additions & 0 deletions packages/@angular/cli/tasks/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export const E2eTask = Task.extend({
additionalProtractorConfig['specs'] = e2eTaskOptions.specs;
}

if (e2eTaskOptions.suite && e2eTaskOptions.suite.length !== 0) {
additionalProtractorConfig['suite'] = e2eTaskOptions.suite;
}

if (e2eTaskOptions.webdriverUpdate) {
// The webdriver-manager update command can only be accessed via a deep import.
const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update';
Expand Down
21 changes: 18 additions & 3 deletions tests/e2e/tests/basic/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
execAndWaitForOutputToMatch,
killAllProcesses
} from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
import { moveFile, copyFile } from '../../utils/fs';
import {updateJsonFile} from '../../utils/project';
import {expectToFail} from '../../utils/utils';
import {moveFile, copyFile, replaceInFile} from '../../utils/fs';


export default function () {
Expand Down Expand Up @@ -34,6 +34,21 @@ export default function () {
.then(() => copyFile('./e2e/renamed-app.e2e-spec.ts', './e2e/another-app.e2e-spec.ts'))
.then(() => ng('e2e', '--specs', './e2e/renamed-app.e2e-spec.ts',
'--specs', './e2e/another-app.e2e-spec.ts'))
// Suites block need to be added in the protractor.conf.js file to test suites
.then(() => replaceInFile('protractor.conf.js', `allScriptsTimeout: 11000,`,
`allScriptsTimeout: 11000,
suites: {
app: './e2e/app.e2e-spec.ts'
},
`))
.then(() => ng('e2e', '--suite=app'))
// remove suites block from protractor.conf.js file after testing suites
.then(() => replaceInFile('protractor.conf.js', `allScriptsTimeout: 11000,
suites: {
app: './e2e/app.e2e-spec.ts'
},
`, `allScriptsTimeout: 11000,`
))
// Should start up Element Explorer
.then(() => execAndWaitForOutputToMatch('ng', ['e2e', '--element-explorer'],
/Element Explorer/))
Expand Down

0 comments on commit 265eb96

Please sign in to comment.