Skip to content

Commit 265eb96

Browse files
aniruddhadas9filipesilva
authored andcommitted
feat(@angular/cli): override suite in the protractor config
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//issues/807 github.com//pull/3551
1 parent f776d3c commit 265eb96

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

docs/documentation/e2e.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ Please note that options that are supported by `ng serve` are also supported by
6060
</p>
6161
</details>
6262

63+
<details>
64+
<summary>suite</summary>
65+
<p>
66+
<code>--suite</code> (aliases: <code>-su</code>)
67+
</p>
68+
<p>
69+
Override suite in the protractor config. Can send in multiple suite by comma separated values (<code>ng e2e --suite=suiteA,suiteB</code>).
70+
</p>
71+
</details>
72+
6373
<details>
6474
<summary>webdriver-update</summary>
6575
<p>

packages/@angular/cli/commands/e2e.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface E2eTaskOptions extends ServeTaskOptions {
1313
serve: boolean;
1414
webdriverUpdate: boolean;
1515
specs: string[];
16+
suite: string;
1617
elementExplorer: boolean;
1718
}
1819

@@ -42,6 +43,15 @@ const E2eCommand = Command.extend({
4243
Can send in multiple specs by repeating flag (ng e2e --specs=spec1.ts --specs=spec2.ts).
4344
`
4445
},
46+
{
47+
name: 'suite',
48+
type: String,
49+
aliases: ['su'],
50+
description: oneLine`
51+
Override suite in the protractor config.
52+
Can send in multiple suite by comma separated values (ng e2e --suite=suiteA,suiteB).
53+
`
54+
},
4555
{
4656
name: 'element-explorer',
4757
type: Boolean,

packages/@angular/cli/tasks/e2e.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export const E2eTask = Task.extend({
5959
additionalProtractorConfig['specs'] = e2eTaskOptions.specs;
6060
}
6161

62+
if (e2eTaskOptions.suite && e2eTaskOptions.suite.length !== 0) {
63+
additionalProtractorConfig['suite'] = e2eTaskOptions.suite;
64+
}
65+
6266
if (e2eTaskOptions.webdriverUpdate) {
6367
// The webdriver-manager update command can only be accessed via a deep import.
6468
const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update';

tests/e2e/tests/basic/e2e.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
execAndWaitForOutputToMatch,
55
killAllProcesses
66
} from '../../utils/process';
7-
import { updateJsonFile } from '../../utils/project';
8-
import { expectToFail } from '../../utils/utils';
9-
import { moveFile, copyFile } from '../../utils/fs';
7+
import {updateJsonFile} from '../../utils/project';
8+
import {expectToFail} from '../../utils/utils';
9+
import {moveFile, copyFile, replaceInFile} from '../../utils/fs';
1010

1111

1212
export default function () {
@@ -34,6 +34,21 @@ export default function () {
3434
.then(() => copyFile('./e2e/renamed-app.e2e-spec.ts', './e2e/another-app.e2e-spec.ts'))
3535
.then(() => ng('e2e', '--specs', './e2e/renamed-app.e2e-spec.ts',
3636
'--specs', './e2e/another-app.e2e-spec.ts'))
37+
// Suites block need to be added in the protractor.conf.js file to test suites
38+
.then(() => replaceInFile('protractor.conf.js', `allScriptsTimeout: 11000,`,
39+
`allScriptsTimeout: 11000,
40+
suites: {
41+
app: './e2e/app.e2e-spec.ts'
42+
},
43+
`))
44+
.then(() => ng('e2e', '--suite=app'))
45+
// remove suites block from protractor.conf.js file after testing suites
46+
.then(() => replaceInFile('protractor.conf.js', `allScriptsTimeout: 11000,
47+
suites: {
48+
app: './e2e/app.e2e-spec.ts'
49+
},
50+
`, `allScriptsTimeout: 11000,`
51+
))
3752
// Should start up Element Explorer
3853
.then(() => execAndWaitForOutputToMatch('ng', ['e2e', '--element-explorer'],
3954
/Element Explorer/))

0 commit comments

Comments
 (0)