Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
chore(config): allow overriding the default port
Browse files Browse the repository at this point in the history
  • Loading branch information
chirayuk authored and juliemr committed Mar 27, 2014
1 parent d243572 commit cca270c
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 21 deletions.
3 changes: 1 addition & 2 deletions debugging/failureConf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Examples of tests to show how debugging works with Protractor. Tests
// should be run against the testapp.

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',

Expand All @@ -14,7 +13,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

// ----- Options to be passed to minijasminenode.
jasmineNodeOpts: {
Expand Down
2 changes: 1 addition & 1 deletion debugging/timeoutConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

// ----- Options to be passed to minijasminenode.
jasmineNodeOpts: {
Expand Down
2 changes: 1 addition & 1 deletion referenceConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ exports.config = {
//
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
Expand Down
2 changes: 1 addition & 1 deletion spec/altRootConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.config = {
// Selector for the element housing the angular app.
rootElement: 'div#nested-ng-app',

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

jasmineNodeOpts: {
onComplete: null,
Expand Down
11 changes: 6 additions & 5 deletions spec/basic/lib_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var util = require('util');
var port = process.env.HTTP_PORT || '8000';

describe('no protractor at all', function() {
it('should still do normal tests', function() {
Expand Down Expand Up @@ -31,15 +32,15 @@ describe('protractor library', function() {
function() {
browser.get('index.html');
expect(browser.getCurrentUrl()).
toEqual('http://localhost:8000/index.html#/form')
toEqual('http://localhost:'+port+'/index.html#/form')

browser.driver.findElement(protractor.By.linkText('repeater')).click();
expect(browser.driver.getCurrentUrl()).
toEqual('http://localhost:8000/index.html#/repeater');
toEqual('http://localhost:'+port+'/index.html#/repeater');

browser.navigate().back();
expect(browser.driver.getCurrentUrl()).
toEqual('http://localhost:8000/index.html#/form');
toEqual('http://localhost:'+port+'/index.html#/form');
});

it('should export other webdriver classes onto the global protractor',
Expand Down Expand Up @@ -95,11 +96,11 @@ describe('protractor library', function() {
it('should get the absolute URL', function() {
browser.get('index.html');
expect(browser.getLocationAbsUrl()).
toEqual('http://localhost:8000/index.html#/form');
toEqual('http://localhost:'+port+'/index.html#/form');

element(by.linkText('repeater')).click();
expect(browser.getLocationAbsUrl()).
toEqual('http://localhost:8000/index.html#/repeater');
toEqual('http://localhost:'+port+'/index.html#/repeater');
});
})
});
2 changes: 1 addition & 1 deletion spec/basicConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

params: {
login: {
Expand Down
2 changes: 1 addition & 1 deletion spec/ciConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.config = {
'name': 'Protractor smoke tests'
}],

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

params: {
login: {
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumberConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

params: {
login: {
Expand Down
2 changes: 1 addition & 1 deletion spec/junitOutputConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ exports.config = {
}
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),
};
2 changes: 1 addition & 1 deletion spec/mochaConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

params: {
login: {
Expand Down
2 changes: 1 addition & 1 deletion spec/multiConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.config = {
'browserName': 'firefox'
}],

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

params: {
login: {
Expand Down
2 changes: 1 addition & 1 deletion spec/onPrepareConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

onPrepare: function() {
browser.params.password = '12345';
Expand Down
2 changes: 1 addition & 1 deletion spec/onPrepareStringConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports.config = {
'browserName': 'chrome'
},

baseUrl: 'http://localhost:8000',
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),

onPrepare: 'onPrepare/startup.js'
};
7 changes: 5 additions & 2 deletions spec/withLoginConf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// This is the configuration file showing how a suite of tests might
// handle log-in using the onPrepare field.
var port = + (process.env.HTTP_PORT || '8000'),
baseUrl = 'http://localhost:8000';

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',

Expand All @@ -12,7 +15,7 @@ exports.config = {
},

onPrepare: function() {
browser.driver.get('http://localhost:8000/login.html');
browser.driver.get(baseUrl + '/login.html');

browser.driver.findElement(by.id('username')).sendKeys('Jane');
browser.driver.findElement(by.id('password')).sendKeys('1234');
Expand All @@ -28,5 +31,5 @@ exports.config = {
});
},

baseUrl: 'http://localhost:8000',
baseUrl: baseUrl,
};
2 changes: 1 addition & 1 deletion testapp/scripts/web-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var express = require('express');
var util = require('util');
var testApp = express();
var DEFAULT_PORT = 8000;
var DEFAULT_PORT = process.env.HTTP_PORT || 8000;
var testAppDir = process.cwd();

var main = function(argv) {
Expand Down

0 comments on commit cca270c

Please sign in to comment.