UNPKG

1.41 kBJavaScriptView Raw
1const Promise = require('bluebird');
2const _ = require('lodash');
3const utils = require('../utils');
4const testimCustomToken = require('../commons/testimCustomToken');
5const analytics = require('../commons/testimAnalytics');
6const {ArgError} = require('../errors');
7
8class BaseRunner {
9 constructor(strategy) {
10 this.strategy = strategy;
11 this.startTime = Date.now();
12 }
13
14 analyticsExecsStart({ executionId, projectId, sessionType }) {
15 analytics.trackWithCIUser('batch-run-ci', {
16 executionId,
17 projectId,
18 sessionType,
19 });
20 }
21
22 validateConfig(options, testList) {
23 let supportedBrowsers = options.mode === 'extension' ? [
24 'edge-chromium', 'chrome',
25 ] : [
26 'ie11', 'firefox', 'chrome', 'edge', 'edge-chromium', 'safari', 'safari technology preview', 'browser', 'android', 'ios', 'iphone', 'ipad',
27 ];
28 let diff = _.difference(utils.getUniqBrowsers(options, testList), supportedBrowsers);
29
30 if (diff.length > 0) {
31 analytics.trackWithCIUser('invalid-config-run', {
32 browser: diff.join(", "),
33 mode: 'runner'
34 });
35 return Promise.reject(new ArgError(`browser type <${diff}> is not supported in ${options.mode} mode.`));
36 }
37
38 return Promise.resolve(testList);
39 }
40}
41
42module.exports = BaseRunner;