@percy/webdriver-utils 1.27.1-beta.0 → 1.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import ProviderResolver from './providers/providerResolver.js';
|
|
2
2
|
import utils from '@percy/sdk-utils';
|
|
3
|
-
import { camelcase } from '@percy/config/utils';
|
|
4
3
|
export default class WebdriverUtils {
|
|
5
|
-
|
|
6
|
-
constructor({
|
|
4
|
+
static async automateScreenshot({
|
|
7
5
|
sessionId,
|
|
8
6
|
commandExecutorUrl,
|
|
9
7
|
capabilities,
|
|
@@ -14,36 +12,21 @@ export default class WebdriverUtils {
|
|
|
14
12
|
options = {},
|
|
15
13
|
buildInfo = {}
|
|
16
14
|
}) {
|
|
17
|
-
|
|
18
|
-
this.commandExecutorUrl = commandExecutorUrl;
|
|
19
|
-
this.capabilities = capabilities;
|
|
20
|
-
this.sessionCapabilites = sessionCapabilites;
|
|
21
|
-
this.snapshotName = snapshotName;
|
|
22
|
-
const camelCasedOptions = {};
|
|
23
|
-
Object.keys(options).forEach(key => {
|
|
24
|
-
let newKey = camelcase(key);
|
|
25
|
-
camelCasedOptions[newKey] = options[key];
|
|
26
|
-
});
|
|
27
|
-
this.options = camelCasedOptions;
|
|
28
|
-
this.clientInfo = clientInfo;
|
|
29
|
-
this.environmentInfo = environmentInfo;
|
|
30
|
-
this.buildInfo = buildInfo;
|
|
31
|
-
}
|
|
32
|
-
async automateScreenshot() {
|
|
15
|
+
const log = utils.logger('webdriver-utils:automateScreenshot');
|
|
33
16
|
try {
|
|
34
17
|
const startTime = Date.now();
|
|
35
|
-
|
|
36
|
-
const automate = ProviderResolver.resolve(
|
|
37
|
-
|
|
18
|
+
log.info(`[${snapshotName}] : Starting automate screenshot ...`);
|
|
19
|
+
const automate = ProviderResolver.resolve(sessionId, commandExecutorUrl, capabilities, sessionCapabilites, clientInfo, environmentInfo, options, buildInfo);
|
|
20
|
+
log.debug(`[${snapshotName}] : Resolved provider ...`);
|
|
38
21
|
await automate.createDriver();
|
|
39
|
-
|
|
40
|
-
const comparisonData = await automate.screenshot(
|
|
22
|
+
log.debug(`[${snapshotName}] : Created driver ...`);
|
|
23
|
+
const comparisonData = await automate.screenshot(snapshotName, options);
|
|
41
24
|
comparisonData.metadata.cliScreenshotStartTime = startTime;
|
|
42
25
|
comparisonData.metadata.cliScreenshotEndTime = Date.now();
|
|
43
26
|
return comparisonData;
|
|
44
27
|
} catch (e) {
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
log.error(`[${snapshotName}] : Error - ${e.message}`);
|
|
29
|
+
log.error(`[${snapshotName}] : Error Log - ${e.toString()}`);
|
|
47
30
|
}
|
|
48
31
|
}
|
|
49
32
|
}
|
|
@@ -5,7 +5,7 @@ export default class MetaDataResolver {
|
|
|
5
5
|
var _capabilities$platfor, _capabilities$device, _capabilities$device$;
|
|
6
6
|
if (!driver) throw new Error('Please pass a Driver object');
|
|
7
7
|
const platform = opts.platformName || opts.platform;
|
|
8
|
-
if (['ios', 'android'].includes(platform.toLowerCase()) || ['ios', 'android'].includes(capabilities === null || capabilities === void 0 ? void 0 : (_capabilities$platfor = capabilities.platformName) === null || _capabilities$platfor === void 0 ? void 0 : _capabilities$platfor.toLowerCase()) || ['ipad', 'iphone'].includes(capabilities === null || capabilities === void 0 ? void 0 : (_capabilities$device = capabilities.device) === null || _capabilities$device === void 0 ? void 0 : (_capabilities$device$ = _capabilities$device.toString()) === null || _capabilities$device$ === void 0 ? void 0 : _capabilities$device$.toLowerCase())) {
|
|
8
|
+
if (['ios', 'android'].includes(platform.toLowerCase()) || ['ios', 'android'].includes(capabilities === null || capabilities === void 0 ? void 0 : (_capabilities$platfor = capabilities.platformName) === null || _capabilities$platfor === void 0 ? void 0 : _capabilities$platfor.toLowerCase()) || ['ipad', 'iphone'].includes(capabilities === null || capabilities === void 0 ? void 0 : (_capabilities$device = capabilities.device) === null || _capabilities$device === void 0 ? void 0 : (_capabilities$device$ = _capabilities$device.toString()) === null || _capabilities$device$ === void 0 ? void 0 : _capabilities$device$.toLowerCase()) || (opts === null || opts === void 0 ? void 0 : opts.deviceName) !== undefined) {
|
|
9
9
|
return new MobileMetaData(driver, capabilities);
|
|
10
10
|
} else {
|
|
11
11
|
return new DesktopMetaData(driver, capabilities);
|
|
@@ -3,10 +3,8 @@ import GenericProvider from './genericProvider.js';
|
|
|
3
3
|
import Cache from '../util/cache.js';
|
|
4
4
|
import Tile from '../util/tile.js';
|
|
5
5
|
import NormalizeData from '../metadata/normalizeData.js';
|
|
6
|
+
import TimeIt from '../util/timing.js';
|
|
6
7
|
const log = utils.logger('webdriver-utils:automateProvider');
|
|
7
|
-
const {
|
|
8
|
-
TimeIt
|
|
9
|
-
} = utils;
|
|
10
8
|
export default class AutomateProvider extends GenericProvider {
|
|
11
9
|
constructor(sessionId, commandExecutorUrl, capabilities, sessionCapabilites, clientInfo, environmentInfo, options, buildInfo) {
|
|
12
10
|
super(sessionId, commandExecutorUrl, capabilities, sessionCapabilites, clientInfo, environmentInfo, options, buildInfo);
|
package/dist/util/cache.js
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Undefined } from './validations.js';
|
|
2
|
+
export default class TimeIt {
|
|
3
|
+
static data = {};
|
|
4
|
+
static enabled = process.env.PERCY_METRICS === 'true';
|
|
5
|
+
static async run(store, func) {
|
|
6
|
+
if (!this.enabled) return await func();
|
|
7
|
+
const t1 = Date.now();
|
|
8
|
+
try {
|
|
9
|
+
return await func();
|
|
10
|
+
} finally {
|
|
11
|
+
if (Undefined(this.data[store])) this.data[store] = [];
|
|
12
|
+
this.data[store].push(Date.now() - t1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
static min(store) {
|
|
16
|
+
return Math.min(...this.data[store]);
|
|
17
|
+
}
|
|
18
|
+
static max(store) {
|
|
19
|
+
return Math.max(...this.data[store]);
|
|
20
|
+
}
|
|
21
|
+
static avg(store) {
|
|
22
|
+
const vals = this.data[store];
|
|
23
|
+
return vals.reduce((a, b) => a + b, 0) / vals.length;
|
|
24
|
+
}
|
|
25
|
+
static summary({
|
|
26
|
+
includeVals
|
|
27
|
+
} = {}) {
|
|
28
|
+
const agg = {};
|
|
29
|
+
for (const key of Object.keys(this.data)) {
|
|
30
|
+
agg[key] = {
|
|
31
|
+
min: this.min(key),
|
|
32
|
+
max: this.max(key),
|
|
33
|
+
avg: this.avg(key),
|
|
34
|
+
count: this.data[key].length
|
|
35
|
+
};
|
|
36
|
+
if (includeVals) agg[key].vals = this.data[key];
|
|
37
|
+
}
|
|
38
|
+
return agg;
|
|
39
|
+
}
|
|
40
|
+
static reset() {
|
|
41
|
+
this.data = {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/webdriver-utils",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "latest"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test:coverage": "yarn test --coverage"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@percy/config": "1.27.
|
|
33
|
-
"@percy/sdk-utils": "1.27.
|
|
32
|
+
"@percy/config": "1.27.2",
|
|
33
|
+
"@percy/sdk-utils": "1.27.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "cb64b0c124a5ee1fcb14b130a1fa8e33d26a7284"
|
|
36
36
|
}
|