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

Commit a368de0

Browse files
elgalujuliemr
authored andcommitted
test(config): added a common configuration environment.js
1 parent 0500b2c commit a368de0

18 files changed

+110
-81
lines changed

Diff for: debugging/failureConf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
var env = require('../environment.js');
2+
13
// Examples of tests to show how debugging works with Protractor. Tests
24
// should be run against the testapp.
35
exports.config = {
4-
seleniumAddress: 'http://localhost:4444/wd/hub',
6+
seleniumAddress: env.seleniumAddress,
57

68
// Spec patterns are relative to the current working directly when
79
// protractor is called.
810
specs: [
911
'failure_spec.js',
1012
],
1113

12-
capabilities: {
13-
'browserName': 'chrome'
14-
},
14+
capabilities: env.capabilities,
1515

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

1818
// ----- Options to be passed to minijasminenode.
1919
jasmineNodeOpts: {

Diff for: debugging/timeoutConf.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1+
var env = require('../environment.js');
2+
13
// Examples of tests to show how timeouts works with Protractor. Tests
24
// should be run against the testapp.
3-
45
exports.config = {
5-
seleniumAddress: 'http://localhost:4444/wd/hub',
6+
seleniumAddress: env.seleniumAddress,
67

78
// Spec patterns are relative to the current working directly when
89
// protractor is called.
910
specs: [
1011
'timeout_spec.js',
1112
],
1213

13-
capabilities: {
14-
'browserName': 'chrome'
15-
},
14+
capabilities: env.capabilities,
1615

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

1918
// ----- Options to be passed to minijasminenode.
2019
jasmineNodeOpts: {

Diff for: spec/altRootConf.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
var env = require('./environment.js');
2+
13
// Tests for an Angular app where ng-app is not on the body.
24
exports.config = {
3-
seleniumAddress: 'http://localhost:4444/wd/hub',
5+
seleniumAddress: env.seleniumAddress,
46

57
// Spec patterns are relative to this config.
68
specs: [
79
'altRoot/*_spec.js',
810
],
911

10-
capabilities: {
11-
'browserName': 'chrome'
12-
},
12+
capabilities: env.capabilities,
1313

14-
// Selector for the element housing the angular app.
15-
rootElement: 'div#nested-ng-app',
14+
baseUrl: env.baseUrl,
1615

17-
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),
16+
// Selector for the element housing the angular app.
17+
rootElement: 'div#nested-ng-app'
1818
};

Diff for: spec/basic/navigation_spec.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var env = require('../environment.js');
2+
13
describe('navigation', function() {
24
beforeEach(function() {
35
browser.get('index.html#/form');
@@ -28,33 +30,31 @@ describe('navigation', function() {
2830
// bootstrapping with Angular
2931
/*
3032
it('should navigate back and forward properly', function() {
31-
var port = process.env.HTTP_PORT || '8000';
3233
browser.get('index.html#/repeater');
3334
expect(browser.getCurrentUrl()).
34-
toEqual('http://localhost:'+port+'/index.html#/repeater');
35+
toEqual(env.baseUrl+'/index.html#/repeater');
3536
3637
browser.navigate().back();
3738
expect(browser.getCurrentUrl()).
38-
toEqual('http://localhost:'+port+'/index.html#/form');
39+
toEqual(env.baseUrl+'/index.html#/form');
3940
4041
browser.navigate().forward();
4142
expect(browser.getCurrentUrl()).
42-
toEqual('http://localhost:'+port+'/index.html#/repeater');
43+
toEqual(env.baseUrl+'/index.html#/repeater');
4344
});
4445
*/
4546

4647
it('should navigate back and forward properly from link', function() {
47-
var port = process.env.HTTP_PORT || '8000';
4848
element(by.linkText('repeater')).click();
4949
expect(browser.getCurrentUrl()).
50-
toEqual('http://localhost:'+port+'/index.html#/repeater');
50+
toEqual(env.baseUrl+'/index.html#/repeater');
5151

5252
browser.navigate().back();
5353
expect(browser.getCurrentUrl()).
54-
toEqual('http://localhost:'+port+'/index.html#/form');
54+
toEqual(env.baseUrl+'/index.html#/form');
5555

5656
browser.navigate().forward();
5757
expect(browser.getCurrentUrl()).
58-
toEqual('http://localhost:'+port+'/index.html#/repeater');
58+
toEqual(env.baseUrl+'/index.html#/repeater');
5959
});
6060
});

Diff for: spec/basicConf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
var env = require('./environment.js');
2+
13
// The main suite of Protractor tests.
24
exports.config = {
3-
seleniumAddress: 'http://localhost:4444/wd/hub',
5+
seleniumAddress: env.seleniumAddress,
46

57
// Spec patterns are relative to this directory.
68
specs: [
@@ -14,11 +16,9 @@ exports.config = {
1416

1517
chromeOnly: false,
1618

17-
capabilities: {
18-
'browserName': 'chrome'
19-
},
19+
capabilities: env.capabilities,
2020

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

2323
params: {
2424
login: {

Diff for: spec/ciConf.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var env = require('./environment.js');
2+
13
// The main suite of Protractor tests to be run on CI servers.
24
exports.config = {
35
sauceUser: process.env.SAUCE_USERNAME,
@@ -30,7 +32,7 @@ exports.config = {
3032
'selenium-version': '2.41.0'
3133
}],
3234

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

3537
params: {
3638
login: {

Diff for: spec/cucumberConf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
var env = require('./environment.js');
2+
13
// A small suite to make sure the cucumber framework works.
24
exports.config = {
3-
seleniumAddress: 'http://localhost:4444/wd/hub',
5+
seleniumAddress: env.seleniumAddress,
46

57
framework: 'cucumber',
68

@@ -9,11 +11,9 @@ exports.config = {
911
'cucumber/*.feature'
1012
],
1113

12-
capabilities: {
13-
'browserName': 'chrome'
14-
},
14+
capabilities: env.capabilities,
1515

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

1818
cucumberOpts: {
1919
require: 'cucumber/stepDefinitions.js',

Diff for: spec/environment.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Common configuration files with defaults plus overrides from environment vars
2+
module.exports = {
3+
// The address of a running selenium server.
4+
seleniumAddress:
5+
(process.env.SELENIUM_URL || 'http://localhost:4444/wd/hub'),
6+
7+
// Capabilities to be passed to the webdriver instance.
8+
capabilities: {
9+
'browserName':
10+
(process.env.TEST_BROWSER_NAME || 'chrome'),
11+
'version':
12+
(process.env.TEST_BROWSER_VERSION || 'ANY')
13+
},
14+
15+
// A base URL for your application under test.
16+
baseUrl:
17+
'http://' + (process.env.HTTP_HOST || 'localhost') +
18+
':' + (process.env.HTTP_PORT || '8000')
19+
20+
};

Diff for: spec/junitOutputConf.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
var env = require('./environment.js');
2+
13
// This configuration file shows an example of using an Jasmine reporter to
24
// output test results in XML format. Before running, you will need to
35
// npm install jasmine-reporters
46

57
// The main suite of Protractor tests.
68
exports.config = {
7-
seleniumAddress: 'http://localhost:4444/wd/hub',
9+
seleniumAddress: env.seleniumAddress,
810

911
specs: [
1012
'basic/*_spec.js'
1113
],
1214

13-
capabilities: {
14-
'browserName': 'chrome'
15-
},
15+
capabilities: env.capabilities,
16+
17+
baseUrl: env.baseUrl,
1618

1719
onPrepare: function() {
1820
// The require statement must be down here, since jasmine-reporters
@@ -28,7 +30,5 @@ exports.config = {
2830
user: 'Jane',
2931
password: '1234'
3032
}
31-
},
32-
33-
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),
33+
}
3434
};

Diff for: spec/login/login_spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
var env = require('../environment.js');
2+
13
describe('pages with login', function() {
24
it('should log in with a non-Angular page', function() {
3-
browser.get('http://localhost:8000/index.html');
5+
browser.get(env.baseUrl+'/index.html');
46

57
var angularElement = element(by.model('username'));
68
expect(angularElement.getAttribute('value')).toEqual('Anon');

Diff for: spec/mochaConf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
var env = require('./environment.js');
2+
13
// A small suite to make sure the mocha frameowork works.
24
exports.config = {
3-
seleniumAddress: 'http://localhost:4444/wd/hub',
5+
seleniumAddress: env.seleniumAddress,
46

57
framework: 'mocha',
68

@@ -9,9 +11,7 @@ exports.config = {
911
'mocha/*_spec.js'
1012
],
1113

12-
capabilities: {
13-
'browserName': 'chrome'
14-
},
14+
capabilities: env.capabilities,
1515

16-
baseUrl: 'http://localhost:' + (process.env.HTTP_PORT || '8000'),
16+
baseUrl: env.baseUrl,
1717
};

Diff for: spec/multiConf.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// A suite of tests to run on two browsers at once.
2+
var env = require('./environment.js');
3+
24
exports.config = {
3-
seleniumAddress: 'http://localhost:4444/wd/hub',
5+
seleniumAddress: env.seleniumAddress,
46

57
// Spec patterns are relative to this directory.
68
specs: [
@@ -15,7 +17,7 @@ exports.config = {
1517
'browserName': 'firefox'
1618
}],
1719

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

2022
params: {
2123
login: {

Diff for: spec/multiSplitConf.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// A suite of tests to run on two browsers at once, splitting test files between
22
// the two instances of chrome.
3+
var env = require('./environment.js');
4+
35
exports.config = {
4-
seleniumAddress: 'http://localhost:4444/wd/hub',
6+
seleniumAddress: env.seleniumAddress,
57

68
// Spec patterns are relative to this directory.
79
specs: [
@@ -21,7 +23,7 @@ exports.config = {
2123
count: 2
2224
}],
2325

24-
baseUrl: 'http://localhost:8000',
26+
baseUrl: env.baseUrl,
2527

2628
params: {
2729
login: {

Diff for: spec/onPrepareConf.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// Configuration using a function in onPrepare to set a parameter before
22
// testing.
3+
var env = require('./environment.js');
4+
5+
// The main suite of Protractor tests.
36
exports.config = {
4-
seleniumAddress: 'http://localhost:4444/wd/hub',
7+
seleniumAddress: env.seleniumAddress,
58

69
specs: [
710
'onPrepare/*_spec.js'
811
],
912

10-
capabilities: {
11-
'browserName': 'chrome'
12-
},
13+
capabilities: env.capabilities,
1314

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

1617
onPrepare: function() {
1718
browser.params.password = '12345';

Diff for: spec/onPrepareFileConf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
var env = require('./environment.js');
2+
13
// Configuration using a string in onPrepare to load a file with code to
24
// execute once before tests.
35
exports.config = {
4-
seleniumAddress: 'http://localhost:4444/wd/hub',
6+
seleniumAddress: env.seleniumAddress,
57

68
// Spec patterns are relative to this directory.
79
specs: [
810
'onPrepare/*_spec.js'
911
],
1012

11-
capabilities: {
12-
'browserName': 'chrome'
13-
},
13+
capabilities: env.capabilities,
1414

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

1717
onPrepare: 'onPrepare/startup.js'
1818
};

Diff for: spec/smokeConf.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var env = require('./environment.js');
2+
13
// Smoke tests to be run on CI servers - covers more browsers than
24
// ciConf.js, but does not run all tests.
35
exports.config = {
@@ -45,7 +47,7 @@ exports.config = {
4547
'platform': 'Windows 7'
4648
}],
4749

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

5052
params: {
5153
login: {

Diff for: spec/suitesConf.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
var env = require('./environment.js');
2+
13
exports.config = {
2-
seleniumAddress: 'http://localhost:4444/wd/hub',
4+
seleniumAddress: env.seleniumAddress,
35

46
// Spec patterns are relative to this directory.
57
suites: {
@@ -8,9 +10,9 @@ exports.config = {
810
failingtest: 'suites/always_fail_spec.js'
911
},
1012

11-
capabilities: {
12-
'browserName': 'chrome'
13-
},
13+
chromeOnly: false,
14+
15+
capabilities: env.capabilities,
1416

15-
baseUrl: 'http://localhost:8000',
17+
baseUrl: env.baseUrl,
1618
};

0 commit comments

Comments
 (0)