-
Notifications
You must be signed in to change notification settings - Fork 40
/
protractor-conf.js
179 lines (142 loc) · 4.68 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* global browser, angular, document, beforeEach, afterEach, jasmine */
'use strict';
var fs = require('fs');
var glob = require('glob');
var config = {};
try {
config = require(process.cwd() + '/protractor-base-conf').config;
} catch (e) {
}
try {
require('wix-eyes-env');
} catch (e) {
}
try {
require('screenshot-reporter-env');
} catch (e) {
}
//temporary, needs to be removed when we upgrade to protractor 4.0
config.chromeDriver = require.resolve('chromedriver/bin/chromedriver');
config.allScriptsTimeout = 120000;
config.baseUrl = 'http://localhost:9876/';
config.specs = [
process.cwd() + '/test/spec/e2e/**/*.js',
process.cwd() + '/test/e2e/spec/**/*.js',
process.cwd() + '/app/test/spec/e2e/**/*.js',
process.cwd() + '/app/test/e2e/spec/**/*.js'
];
config.framework = 'jasmine2';
config.directConnect = true;
config.capabilities = Object.assign({
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 6
}, config.capabilities);
function hasFocusedTests(patterns, stringsRegex) {
var commentsRegex = /(?:\/\*(?:[\s\S]*?)\*\/)|(?:^[\s;]*\/\/.*$)/gm;
return patterns.some(function (pattern) {
return glob.sync(pattern).some(function (file) {
var fileContent = fs.readFileSync(file, 'utf-8');
fileContent = fileContent.replace(commentsRegex, '');
return stringsRegex.test(fileContent);
});
});
}
function warn(message) {
console.log('\x1b[33m%s\x1b[0m', message);
}
if (hasFocusedTests(config.specs, new RegExp('^\\s*\\b(iit|fit|ddescribe|fdescribe|tthey|fthey|eyes\.fit)\\s*\\(', 'gm'))) {
config.capabilities.shardTestFiles = false;
warn('Protractor sharding is disabled due to presence of focused tests.');
}
var onPrepare = config.onPrepare || function () {};
config.onPrepare = function () {
require('babel/register');
console.log('onPrepare!!!');
try {
var ScreenshotReporter = require('screenshot-reporter');
jasmine.getEnv().addReporter(new ScreenshotReporter());
} catch (e) {}
// Disable animations so e2e tests run more quickly
var disableNgAnimate = function () {
angular.module('disableNgAnimate', []).run(function ($animate) {
$animate.enabled(false);
});
};
var disableCssAnimate = function () {
angular.module('disableCssAnimate', []).run(function () {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '* {' +
'-webkit-transition: none !important;' +
'-moz-transition: none !important;' +
'-o-transition: none !important;' +
'-ms-transition: none !important;' +
'transition: none !important;' +
'}';
document.getElementsByTagName('head')[0].appendChild(style);
});
};
var biLoggerDryRun = function () {
angular.module('biLoggerDryRun', []).config(function () {
/* global W */
if (typeof W !== 'undefined' && W.BI) {
W.BI.DryRun = true;
}
});
};
var disableTimeouts = function () {
angular.module('disableTimeouts', [])
.config(function ($provide) {
$provide.decorator('$timeout', function ($delegate) {
var mockTimeout = function () {
arguments[typeof arguments[0] === 'function' ? 1 : 0] = 0;
return $delegate.apply(this, arguments);
};
angular.extend(mockTimeout, $delegate);
return mockTimeout;
});
});
};
beforeEach(function () {
browser.addMockModule('disableNgAnimate', disableNgAnimate);
browser.addMockModule('disableCssAnimate', disableCssAnimate);
browser.addMockModule('biLoggerDryRun', biLoggerDryRun);
browser.addMockModule('disableTimeouts', disableTimeouts);
});
afterEach(function () {
browser.removeMockModule('disableNgAnimate');
browser.removeMockModule('disableCssAnimate');
browser.removeMockModule('biLoggerDryRun');
browser.removeMockModule('disableTimeouts');
});
// Store the name of the browser that's currently being used.
browser.getCapabilities().then(function (caps) {
browser.params.browser = caps.get('browserName');
});
onPrepare.apply(this, arguments);
};
config.jasmineNodeOpts = {
defaultTimeoutInterval: 300000,
isVerbose: true
};
config.capabilities.loggingPrefs = {
browser: 'ALL'
};
var originalOnPrepare = config.onPrepare;
config.onPrepare = function () {
var browserLogs = require('protractor-browser-logs'),
logs = browserLogs(browser);
global.logs = logs;
beforeEach(function () {
logs.reset();
logs.ignore(logs.DEBUG);
logs.ignore(logs.INFO);
logs.ignore(logs.LOG);
logs.ignore('favicon.ico');
logs.ignore('cast_sender.js');
});
afterEach(logs.verify);
originalOnPrepare.apply(this, arguments);
};
module.exports.config = config;