-
Notifications
You must be signed in to change notification settings - Fork 0
/
protractor.conf.js
116 lines (109 loc) · 3.92 KB
/
protractor.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Stores the configuration of Protractor. It is loaded by protractor to run
* tests.
*
* Usage:
*
* Run locally with PhantomJS:
* $ npm test
* It will start a local Selenium Webdriver server as well as the HTTP server
* that serves test files.
*
* Run locally using SauceLabs:
* Go to your SauceLab account, under "My Account", and copy paste the
* access key. Now export the following variables:
* $ export SAUCE_USERNAME=<your username>
* $ export SAUCE_ACCESS_KEY=<the copy pasted access key>
* Then, start SauceConnect:
* $ ./buildtools/sauce_connect.sh
* Take note of the "Tunnel Identifier" value logged in the terminal.
* Run the tests:
* $ npm test -- --saucelabs --tunnelIdentifier=<the tunnel identifier>
* This will start the HTTP Server locally, and connect through SauceConnect
* to SauceLabs remote browsers instances.
*
* Github will run `npm test -- --saucelabs`.
*/
// Common configuration.
config = {
// Using jasmine to wrap Closure JSUnit tests.
framework: 'jasmine',
// The jasmine specs to run.
specs: ['protractor_spec.js'],
// Jasmine options. Increase the timeout to 5min instead of the default 30s.
jasmineNodeOpts: {
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 20 * 60 * 1000
},
chromeDriver: require(`chromedriver/lib/chromedriver`).path
};
// Read arguments to the protractor command.
// The first 3 arguments are something similar to:
// [ '.../bin/node',
// '.../node_modules/.bin/protractor',
// 'protractor.conf.js' ]
var arguments = process.argv.slice(3);
// Default options: run tests locally (saucelabs false) and use the env variable
// GITHUB_RUN_ID to get the tunnel identifier, when using saucelabs.
var options = {
saucelabs: false,
tunnelIdentifier: process.env.GITHUB_RUN_ID
};
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (arg == '--saucelabs') {
options.saucelabs = true;
} else if (arg.indexOf('--tunnelIdentifier') == 0) {
options.tunnelIdentifier = arg.split('=')[1];
}
}
if (options.saucelabs) {
if (!options.tunnelIdentifier) {
throw 'No tunnel identifier given! Either the GITHUB_RUN_ID is not ' +
'set, or you haven\'t passed the --tunnelIdentifier=xxx argument.';
}
// SauceLabs configuration.
config.sauceUser = process.env.SAUCE_USERNAME;
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
if (!config.sauceKey || !config.sauceUser) {
throw 'The SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables have '+
' to be set.';
}
// Avoid going over the SauceLabs concurrency limit (5).
config.maxSessions = 5;
config.allScriptsTimeout = 10 * 60 * 1000;
// List of browsers configurations tested.
var sauceBrowsers = require('./sauce_browsers.json');
// Configuration for SauceLabs browsers.
config.multiCapabilities = sauceBrowsers.map(function(browser) {
browser['tunnel-identifier'] = options.tunnelIdentifier;
browser.maxDuration = 2000;
browser.commandTimeout = 600;
browser.idleTimeout = 120;
return browser;
});
} else {
// Configuration for headless chrome.
config.directConnect = true;
config.multiCapabilities = [{
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800,600",
"--no-sandbox", "--disable-dev-shm-usage" ]
}
}];
}
exports.config = config;