Skip to content

feat(@angular/cli) override suite in the protractor config #8354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good test. I tried to do this without the your PR and e2e broke with Error: Unknown test suite: app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :). Yap, I also tried same and some other combination and thought to add suites and then test it.

`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