-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
34 lines (29 loc) · 1.16 KB
/
index.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
'use strict';
const _ = require('lodash');
const parseConfig = require('./lib/parse-config');
const downloadChromiumByVersion = require('./lib/download-chromium-by-version');
module.exports = async (testplane, opts) => {
const config = parseConfig(opts);
if (!config.enabled) {
return;
}
const browser = testplane.config.browsers[config.browserId];
if (_.isUndefined(browser)) {
throw new Error('Headless browser id was not specified in testplane config');
}
testplane.on(testplane.events.INIT, async () => {
if (!testplane.isWorker()) {
const {version, cachePath, downloadAttempts} = config;
const chromiumPath = await downloadChromiumByVersion(version, cachePath, downloadAttempts);
const {desiredCapabilities} = browser;
desiredCapabilities['goog:chromeOptions'] = _.mergeWith(desiredCapabilities['goog:chromeOptions'], {
args: ['headless'],
binary: chromiumPath
}, (objValue) => {
if (_.isArray(objValue)) {
return _.union(objValue, ['headless']);
}
});
}
});
};