-
Notifications
You must be signed in to change notification settings - Fork 12k
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
feat(e2e): use protractor api #4527
Merged
+187
−78
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,50 @@ | ||
import * as url from 'url'; | ||
|
||
import { E2eTaskOptions } from '../commands/e2e'; | ||
import { requireProjectModule } from '../utilities/require-project-module'; | ||
const Task = require('../ember-cli/lib/models/task'); | ||
import * as chalk from 'chalk'; | ||
import {exec} from 'child_process'; | ||
|
||
|
||
export const E2eTask = Task.extend({ | ||
run: function () { | ||
const ui = this.ui; | ||
let exitCode = 0; | ||
|
||
return new Promise((resolve) => { | ||
exec(`npm run e2e -- ${this.project.ngConfig.config.e2e.protractor.config}`, | ||
(err: NodeJS.ErrnoException, stdout: string, stderr: string) => { | ||
ui.writeLine(stdout); | ||
if (err) { | ||
ui.writeLine(stderr); | ||
ui.writeLine(chalk.red('Some end-to-end tests failed, see above.')); | ||
exitCode = 1; | ||
} else { | ||
ui.writeLine(chalk.green('All end-to-end tests pass.')); | ||
} | ||
resolve(exitCode); | ||
run: function (e2eTaskOptions: E2eTaskOptions) { | ||
const projectRoot = this.project.root; | ||
const protractorLauncher = requireProjectModule(projectRoot, 'protractor/built/launcher'); | ||
|
||
return new Promise(function () { | ||
let promise = Promise.resolve(); | ||
let additionalProtractorConfig: any = { | ||
elementExplorer: e2eTaskOptions.elementExplorer | ||
}; | ||
|
||
// use serve url as override for protractors baseUrl | ||
if (e2eTaskOptions.serve) { | ||
additionalProtractorConfig.baseUrl = url.format({ | ||
protocol: e2eTaskOptions.ssl ? 'https' : 'http', | ||
hostname: e2eTaskOptions.host, | ||
port: e2eTaskOptions.port.toString() | ||
}); | ||
} | ||
|
||
if (e2eTaskOptions.specs.length !== 0) { | ||
additionalProtractorConfig['specs'] = e2eTaskOptions.specs; | ||
} | ||
|
||
if (e2eTaskOptions.webdriverUpdate) { | ||
// webdriver-manager can only be accessed via a deep import from within | ||
// protractor/node_modules. A double deep import if you will. | ||
const webdriverUpdate = requireProjectModule(projectRoot, | ||
'protractor/node_modules/webdriver-manager/built/lib/cmds/update'); | ||
// run `webdriver-manager update --standalone false --gecko false --quiet` | ||
promise = promise.then(() => webdriverUpdate.program.run({ | ||
standalone: false, | ||
gecko: false, | ||
quiet: true | ||
})); | ||
} | ||
|
||
// Don't call resolve(), protractor will manage exiting the process itself | ||
return promise.then(() => | ||
protractorLauncher.init(e2eTaskOptions.config, additionalProtractorConfig)); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import * as path from 'path'; | ||
const resolve = require('resolve'); | ||
|
||
// require dependencies within the target project | ||
export function requireDependency(root: string, moduleName: string) { | ||
const packageJson = require(path.join(root, 'node_modules', moduleName, 'package.json')); | ||
const main = path.normalize(packageJson.main); | ||
return require(path.join(root, 'node_modules', moduleName, main)); | ||
export function requireProjectModule(root: string, moduleName: string) { | ||
return require(resolve.sync(moduleName, { basedir: root })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ok for now - This interface is not changing for now. Will see how we can make this public for the future.