-
Notifications
You must be signed in to change notification settings - Fork 128
/
wdio.conf.js
165 lines (149 loc) · 3.94 KB
/
wdio.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
const createHelpers = require('./test/integration/helper');
const uuid = require('@braintree/uuid');
const browserstack = require('browserstack-local');
// Stop node from complaining about fake memory leaks at higher concurrency
require('events').defaultMaxListeners = 20;
require('dotenv').config();
const ONLY_BROWSERS = process.env.ONLY_BROWSERS;
const localIdentifier = uuid();
const projectName = 'Braintee Web Drop-in';
let type;
if (!process.env.GITHUB_REF) {
type = "Local";
} else {
type = "CI";
}
const build = `${projectName} - ${type} ${Date.now()}`;
const desktopCapabilities = {
'bstack:options' : {
os : 'Windows',
osVersion : '10',
local : 'true',
debug : 'true',
seleniumVersion : '3.14.0',
localIdentifier,
},
browserVersion: 'latest',
acceptInsecureCerts: true
};
let capabilities = [
{
...desktopCapabilities,
browserName: 'Chrome',
},
{
...desktopCapabilities,
browserName: 'Firefox',
// TODO remove this version override
// In v97+, the PayPal window never launches
// to unblock current PRs from being merged,
// we're pinning to v96.0, but this should
// be investigated and resolved ASAP
browserVersion: '96.0',
},
];
// TODO check in with PayPal team on this
// Safari is struggling to close the PayPal popup on CI
// skip PayPal on Safari for now
if (!process.env.RUN_PAYPAL_ONLY) {
capabilities.push({
...desktopCapabilities,
browserName: 'Safari',
browserVersion: '14.0',
'bstack:options': {
...desktopCapabilities['bstack:options'],
os: 'OS X',
osVersion: 'Big Sur'
}
});
}
if (ONLY_BROWSERS) {
capabilities = ONLY_BROWSERS.split(',')
.map(browser => capabilities.find(config => config.browserName.toLowerCase() === browser.toLowerCase()))
.filter(b => b); // in case an invalid value is passed and no corresponding capability is available
if (capabilities.length === 0) {
throw new Error(`Could not find browsers ${ONLY_BROWSERS} in config`);
}
}
const mochaOpts = {
timeout: 200000
};
if (!process.env.DISABLE_RETRIES) {
mochaOpts.retries = 3;
}
if (process.env.TEST_GREP) {
mochaOpts.grep = process.env.TEST_GREP;
} else if (process.env.RUN_PAYPAL_ONLY) {
mochaOpts.grep = '@paypal';
} else if (process.env.SKIP_PAYPAL) {
mochaOpts.grep = '@paypal';
mochaOpts.invert = 1;
}
exports.config = {
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
specs: require('fs')
.readdirSync('./test/integration')
.map(f => `./test/integration/${f}`),
exclude: [
'./test/integration/helper.js'
],
maxInstances: 4,
capabilities,
sync: true,
logLevel: 'error',
deprecationWarnings: true,
bail: 0,
waitforTimeout: 20000,
connectionRetryTimeout: 90000,
connectionRetryCount: 1,
services: [
['browserstack', {
runner: 'local',
browserstackLocal: true,
}],
],
framework: 'mocha',
mochaOpts,
reporters: ['spec'],
reportOptions: {
outputDir: './'
},
onPrepare() {
/* eslint-disable no-console */
console.log('Connecting local');
return new Promise((resolve, reject) => {
exports.bs_local = new browserstack.Local();
exports.bs_local.start(
{
key: process.env.BROWSERSTACK_ACCESS_KEY,
localIdentifier
},
error => {
if (error) return reject(error);
console.log(`Connected with localIdentifier=${localIdentifier}`);
console.log(
'Testing in the following browsers:',
capabilities
.map(
browser => `${browser.browserName}@${browser.browserVersion}`
)
.join(', ')
);
return resolve();
}
);
});
/* eslint-enable no-console */
},
before(capabilities) {
createHelpers();
browser.setTimeout({
pageLoad: 10000,
script: 5 * 60 * 1000
});
},
onComplete() {
exports.bs_local.stop(() => {});
}
};