Skip to content

Commit

Permalink
feat(protractor): update protractor to reflect changes for running wi…
Browse files Browse the repository at this point in the history
…th custom port & host

Also update cypress.config.js, this one missed in the previous commit
  • Loading branch information
shahabganji authored and 3cp committed Sep 3, 2019
1 parent 50c7de5 commit 770fd87
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 22 deletions.
6 changes: 4 additions & 2 deletions skeleton/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const CLIOptions = require( 'aurelia-cli').CLIOptions;
const aureliaConfig = require('./aurelia_project/aurelia.json');
const port = aureliaConfig.platform.port;
const PORT = CLIOptions.getFlagValue('port') || aureliaConfig.platform.port;
const HOST = CLIOptions.getFlagValue('host') || aureliaConfig.platform.host;

module.exports = {
config: {
baseUrl: `http://localhost:${port}`,
baseUrl: `http://${HOST}:${PORT}`,
fixturesFolder: 'test/e2e/fixtures',
integrationFolder: 'test/e2e/integration',
pluginsFile: 'test/e2e/plugins/index.js',
Expand Down
34 changes: 24 additions & 10 deletions skeleton/protractor/aurelia_project/tasks/protractor.ext
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,36 @@ import * as gulp from 'gulp';
// @endif
const {protractor, webdriver_update } = require('gulp-protractor');

gulp.task('webdriver_update', webdriver_update);
import { CLIOptions } from 'aurelia-cli';
import { default as runAppServer, shutdownAppServer } from './run';

gulp.task('protractor', (cb) => {
function runApp(cb) {
if (CLIOptions.hasFlag('start')) {
runAppServer();
}
cb();
}

function runProtractor(cb) {
// @if feat.babel
gulp.src('test/e2e/**/*.e2e.js')
return gulp.src('test/e2e/**/*.e2e.js')
// @endif
// @if feat.typescript
gulp.src('test/e2e/**/*.e2e.ts')
return gulp.src('test/e2e/**/*.e2e.ts')
// @endif
.pipe(protractor({configFile: 'test/protractor.conf.js'}))
.on('error', cb)
.on('end', cb);
});
.pipe(protractor({ configFile: 'protractor.conf.js', args: process.argv.slice(3) }))
.on('end', () => {
shutdownAppServer().then(cb);
})
.on('error', () => {
shutdownAppServer(1).then(cb);
});
}

// Setting up the test task
export default gulp.series(
'webdriver_update',
'protractor'
runApp,
webdriver_update,
runProtractor
);

Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
const aureliaConfig = require('../aurelia_project/aurelia.json');
const port = aureliaConfig.platform.port;
const CLIOptions = require('aurelia-cli').CLIOptions;
const aureliaConfig = require('./aurelia_project/aurelia.json');
const cliOptions = new CLIOptions();

exports.config = {
port: port,
Object.assign(cliOptions, {
args: process.argv.slice(3)
});

const port = cliOptions.getFlagValue('port') || aureliaConfig.platform.port;
const host = cliOptions.getFlagValue('host') || aureliaConfig.platform.host || "localhost";
const headless = cliOptions.hasFlag('run') || false;

baseUrl: `http://localhost:${port}/`,
const config = {
port: port,
host: host,
baseUrl: `http://${host}:${port}/`,

specs: [
// @if feat.babel
Expand Down Expand Up @@ -45,11 +54,7 @@ exports.config = {
'--disable-translate',
'--disable-background-timer-throttling',
'--disable-renderer-backgrounding',
'--disable-device-discovery-notifications',
/* enable these if you'd like to test using Chrome Headless
'--no-gpu',
'--headless'
*/
'--disable-device-discovery-notifications'
]
}
},
Expand All @@ -69,3 +74,10 @@ exports.config = {
package: 'aurelia-protractor-plugin'
}],
};

if (headless) {
config.capabilities.chromeOptions.args.push("--no-gpu");
config.capabilities.chromeOptions.args.push("--headless");
}

exports.config = config;

0 comments on commit 770fd87

Please sign in to comment.