@wdio/browserstack-service 8.27.2 → 8.28.4
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/build/Percy/Percy-Handler.d.ts +32 -0
- package/build/Percy/Percy-Handler.d.ts.map +1 -0
- package/build/Percy/Percy-Handler.js +156 -0
- package/build/Percy/Percy.d.ts +15 -0
- package/build/Percy/Percy.d.ts.map +1 -0
- package/build/Percy/Percy.js +123 -0
- package/build/Percy/PercyBinary.d.ts +10 -0
- package/build/Percy/PercyBinary.d.ts.map +1 -0
- package/build/Percy/PercyBinary.js +149 -0
- package/build/Percy/PercyCaptureMap.d.ts +9 -0
- package/build/Percy/PercyCaptureMap.d.ts.map +1 -0
- package/build/Percy/PercyCaptureMap.js +35 -0
- package/build/Percy/PercyHelper.d.ts +8 -0
- package/build/Percy/PercyHelper.d.ts.map +1 -0
- package/build/Percy/PercyHelper.js +67 -0
- package/build/Percy/PercyLogger.d.ts +15 -0
- package/build/Percy/PercyLogger.d.ts.map +1 -0
- package/build/Percy/PercyLogger.js +67 -0
- package/build/Percy/PercySDK.d.ts +4 -0
- package/build/Percy/PercySDK.d.ts.map +1 -0
- package/build/Percy/PercySDK.js +39 -0
- package/build/bstackLogger.d.ts +1 -1
- package/build/bstackLogger.d.ts.map +1 -1
- package/build/constants.d.ts +3 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +11 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/build/insights-handler.d.ts +0 -1
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +2 -16
- package/build/launcher.d.ts +7 -2
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +70 -1
- package/build/reporter.d.ts +2 -0
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +7 -1
- package/build/service.d.ts +2 -0
- package/build/service.d.ts.map +1 -1
- package/build/service.js +37 -8
- package/build/types.d.ts +16 -0
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +3 -0
- package/build/util.d.ts.map +1 -1
- package/build/util.js +36 -1
- package/package.json +11 -8
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import logger from '@wdio/logger';
|
|
5
|
+
import { PERCY_LOGS_FILE } from '../constants.js';
|
|
6
|
+
import { COLORS } from '../util.js';
|
|
7
|
+
const log = logger('@wdio/browserstack-service');
|
|
8
|
+
export class PercyLogger {
|
|
9
|
+
static logFilePath = path.join(process.cwd(), PERCY_LOGS_FILE);
|
|
10
|
+
static logFolderPath = path.join(process.cwd(), 'logs');
|
|
11
|
+
static logFileStream;
|
|
12
|
+
static logToFile(logMessage, logLevel) {
|
|
13
|
+
try {
|
|
14
|
+
if (!this.logFileStream) {
|
|
15
|
+
if (!fs.existsSync(this.logFolderPath)) {
|
|
16
|
+
fs.mkdirSync(this.logFolderPath);
|
|
17
|
+
}
|
|
18
|
+
this.logFileStream = fs.createWriteStream(this.logFilePath, { flags: 'a' });
|
|
19
|
+
}
|
|
20
|
+
if (this.logFileStream && this.logFileStream.writable) {
|
|
21
|
+
this.logFileStream.write(this.formatLog(logMessage, logLevel));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
log.debug(`Failed to log to file. Error ${error}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static formatLog(logMessage, level) {
|
|
29
|
+
return `${chalk.gray(new Date().toISOString())} ${chalk[COLORS[level]](level.toUpperCase())} ${chalk.whiteBright('@wdio/browserstack-service')} ${logMessage}\n`;
|
|
30
|
+
}
|
|
31
|
+
static info(message) {
|
|
32
|
+
this.logToFile(message, 'info');
|
|
33
|
+
log.info(message);
|
|
34
|
+
}
|
|
35
|
+
static error(message) {
|
|
36
|
+
this.logToFile(message, 'error');
|
|
37
|
+
log.error(message);
|
|
38
|
+
}
|
|
39
|
+
static debug(message, param) {
|
|
40
|
+
this.logToFile(message, 'debug');
|
|
41
|
+
if (param) {
|
|
42
|
+
log.debug(message, param);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
log.debug(message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
static warn(message) {
|
|
49
|
+
this.logToFile(message, 'warn');
|
|
50
|
+
log.warn(message);
|
|
51
|
+
}
|
|
52
|
+
static trace(message) {
|
|
53
|
+
this.logToFile(message, 'trace');
|
|
54
|
+
log.trace(message);
|
|
55
|
+
}
|
|
56
|
+
static clearLogger() {
|
|
57
|
+
if (this.logFileStream) {
|
|
58
|
+
this.logFileStream.end();
|
|
59
|
+
}
|
|
60
|
+
this.logFileStream = null;
|
|
61
|
+
}
|
|
62
|
+
static clearLogFile() {
|
|
63
|
+
if (fs.existsSync(this.logFilePath)) {
|
|
64
|
+
fs.truncateSync(this.logFilePath);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PercySDK.d.ts","sourceRoot":"","sources":["../../src/Percy/PercySDK.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,QAAQ,YAVW,GAAG,EAAE,SAUE,CAAA;AASvC,eAAO,MAAM,UAAU,YANiB,GAAG,EAAE,kBAMF,CAAA;AAS3C,eAAO,MAAM,aAAa,YANiB,GAAG,EAAE,kBAMC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PercyLogger } from './PercyLogger.js';
|
|
2
|
+
const tryRequire = async function (pkg, fallback) {
|
|
3
|
+
try {
|
|
4
|
+
return (await import(pkg)).default;
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return fallback;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const percySnapshot = await tryRequire('@percy/selenium-webdriver', null);
|
|
11
|
+
const percyAppScreenshot = await tryRequire('@percy/appium-app', {});
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
13
|
+
let snapshotHandler = (...args) => {
|
|
14
|
+
PercyLogger.error('Unsupported driver for percy');
|
|
15
|
+
};
|
|
16
|
+
if (percySnapshot) {
|
|
17
|
+
snapshotHandler = (browser, name) => {
|
|
18
|
+
if (process.env.PERCY_SNAPSHOT === 'true') {
|
|
19
|
+
return percySnapshot(browser, name);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export const snapshot = snapshotHandler;
|
|
24
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
+
let screenshotHandler = async (...args) => {
|
|
26
|
+
PercyLogger.error('Unsupported driver for percy');
|
|
27
|
+
};
|
|
28
|
+
if (percySnapshot && percySnapshot.percyScreenshot) {
|
|
29
|
+
screenshotHandler = percySnapshot.percyScreenshot;
|
|
30
|
+
}
|
|
31
|
+
export const screenshot = screenshotHandler;
|
|
32
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
33
|
+
let screenshotAppHandler = async (...args) => {
|
|
34
|
+
PercyLogger.error('Unsupported driver for percy');
|
|
35
|
+
};
|
|
36
|
+
if (percyAppScreenshot) {
|
|
37
|
+
screenshotAppHandler = percyAppScreenshot;
|
|
38
|
+
}
|
|
39
|
+
export const screenshotApp = screenshotAppHandler;
|
package/build/bstackLogger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bstackLogger.d.ts","sourceRoot":"","sources":["../src/bstackLogger.ts"],"names":[],"mappings":"AAWA,
|
|
1
|
+
{"version":3,"file":"bstackLogger.d.ts","sourceRoot":"","sources":["../src/bstackLogger.ts"],"names":[],"mappings":"AAWA,qBAAa,YAAY;IACrB,OAAc,WAAW,SAAsC;IAC/D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAmC;IAC/D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAuB;IAEnD,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAgBrD,OAAO,CAAC,MAAM,CAAC,SAAS;WAIV,IAAI,CAAC,OAAO,EAAE,MAAM;WAKpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAKrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;WASlC,IAAI,CAAC,OAAO,EAAE,MAAM;WAKpB,KAAK,CAAC,OAAO,EAAE,MAAM;WAKrB,WAAW;WAOX,YAAY;CAK7B"}
|
package/build/constants.d.ts
CHANGED
|
@@ -18,4 +18,7 @@ export declare const NOT_ALLOWED_KEYS_IN_CAPS: string[];
|
|
|
18
18
|
export declare const LOGS_FILE = "logs/bstack-wdio-service.log";
|
|
19
19
|
export declare const UPLOAD_LOGS_ADDRESS = "https://upload-observability.browserstack.com";
|
|
20
20
|
export declare const UPLOAD_LOGS_ENDPOINT = "client-logs/upload";
|
|
21
|
+
export declare const PERCY_LOGS_FILE = "logs/percy.log";
|
|
22
|
+
export declare const PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS: string[];
|
|
23
|
+
export declare const CAPTURE_MODES: string[];
|
|
21
24
|
//# sourceMappingURL=constants.d.ts.map
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKpD,eAAO,MAAM,mBAAmB,qHAStB,CAAA;AAEV,eAAO,MAAM,mBAAmB,UAI/B,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,kBAAkB,CAKvD,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,OAAoC,CAAA;AAEvE,eAAO,MAAM,aAAa,qDAAqD,CAAA;AAC/E,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AACjD,eAAO,MAAM,mBAAmB,iBAAiB,CAA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,+CAA+C,CAAA;AACjF,eAAO,MAAM,wBAAwB,UAA6D,CAAA;AAElG,eAAO,MAAM,SAAS,iCAAiC,CAAA;AACvD,eAAO,MAAM,mBAAmB,kDAAkD,CAAA;AAClF,eAAO,MAAM,oBAAoB,uBAAuB,CAAA;AAExD,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAE/C,eAAO,MAAM,qCAAqC,UAQjD,CAAA;AAED,eAAO,MAAM,aAAa,UAAwD,CAAA"}
|
package/build/constants.js
CHANGED
|
@@ -38,3 +38,14 @@ export const NOT_ALLOWED_KEYS_IN_CAPS = ['includeTagsInTestingScope', 'excludeTa
|
|
|
38
38
|
export const LOGS_FILE = 'logs/bstack-wdio-service.log';
|
|
39
39
|
export const UPLOAD_LOGS_ADDRESS = 'https://upload-observability.browserstack.com';
|
|
40
40
|
export const UPLOAD_LOGS_ENDPOINT = 'client-logs/upload';
|
|
41
|
+
export const PERCY_LOGS_FILE = 'logs/percy.log';
|
|
42
|
+
export const PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = [
|
|
43
|
+
'/session/:sessionId/url',
|
|
44
|
+
'/session/:sessionId/forward',
|
|
45
|
+
'/session/:sessionId/back',
|
|
46
|
+
'/session/:sessionId/refresh',
|
|
47
|
+
'/session/:sessionId/screenshot',
|
|
48
|
+
'/session/:sessionId/actions',
|
|
49
|
+
'/session/:sessionId/appium/device/shake'
|
|
50
|
+
];
|
|
51
|
+
export const CAPTURE_MODES = ['click', 'auto', 'screenshot', 'manual', 'testcase'];
|
package/build/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare const log4jsAppender: {
|
|
|
8
8
|
configure: (config: any, layouts: any) => Function;
|
|
9
9
|
};
|
|
10
10
|
export declare const BStackTestOpsLogger: typeof logReportingAPI;
|
|
11
|
+
import * as Percy from './Percy/PercySDK.js';
|
|
12
|
+
export declare const PercySDK: typeof Percy;
|
|
11
13
|
export * from './types.js';
|
|
12
14
|
declare global {
|
|
13
15
|
namespace WebdriverIO {
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,eAAe,CAAA;AAChD,OAAO,mBAAmB,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,eAAe,MAAM,sBAAsB,CAAA;AAElD,eAAe,mBAAmB,CAAA;AAClC,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAC5C,eAAO,MAAM,cAAc;;CAAgB,CAAA;AAC3C,eAAO,MAAM,mBAAmB,wBAAkB,CAAA;AAElD,cAAc,YAAY,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACxD;CACJ"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,MAAM,eAAe,CAAA;AAChD,OAAO,mBAAmB,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,OAAO,eAAe,MAAM,sBAAsB,CAAA;AAElD,eAAe,mBAAmB,CAAA;AAClC,eAAO,MAAM,QAAQ,6BAAuB,CAAA;AAC5C,eAAO,MAAM,cAAc;;CAAgB,CAAA;AAC3C,eAAO,MAAM,mBAAmB,wBAAkB,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAC5C,eAAO,MAAM,QAAQ,cAAQ,CAAA;AAE7B,cAAc,YAAY,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACxD;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -7,4 +7,6 @@ export default BrowserstackService;
|
|
|
7
7
|
export const launcher = BrowserstackLauncher;
|
|
8
8
|
export const log4jsAppender = { configure };
|
|
9
9
|
export const BStackTestOpsLogger = logReportingAPI;
|
|
10
|
+
import * as Percy from './Percy/PercySDK.js';
|
|
11
|
+
export const PercySDK = Percy;
|
|
10
12
|
export * from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insights-handler.d.ts","sourceRoot":"","sources":["../src/insights-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGzE,OAAO,KAAK,EAAiB,OAAO,EAAE,QAAQ,EAAsB,YAAY,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAkBjK,OAAO,KAAK,EAER,QAAQ,EAER,UAAU,EACV,cAAc,EACd,MAAM,EACT,MAAM,YAAY,CAAA;AAInB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,cAAM,gBAAgB;IAiBL,OAAO,CAAC,QAAQ;IAAiF,OAAO,CAAC,UAAU,CAAC;IAhBjI,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,SAAS,CAA2D;IAC5E,OAAO,CAAC,cAAc,CAAC,CAAQ;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,oBAAoB,CAAoC;IAChE,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAIpB;IACD,OAAO,CAAC,SAAS,CAAC,CAAoC;gBAEjC,QAAQ,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAAE,aAAa,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AO,CAAC,aAAa;CAMxB;AAGD,QAAA,MAAM,eAAe,EAAE,OAAO,gBAA0D,CAAA;AACxF,KAAK,eAAe,GAAG,gBAAgB,CAAA;AAEvC,eAAe,eAAe,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import TestReporter from './reporter.js';
|
|
4
|
-
import { frameworkSupportsHook, getCloudProvider, getFailureObject, getGitMetaData, getHookType, getScenarioExamples, getUniqueIdentifier, getUniqueIdentifierForCucumber, isBrowserstackSession, isScreenshotCommand, o11yClassErrorHandler, pushDataToQueue, removeAnsiColors, sleep, uploadEventData } from './util.js';
|
|
4
|
+
import { frameworkSupportsHook, getCloudProvider, getFailureObject, getGitMetaData, getHookType, getPlatformVersion, getScenarioExamples, getUniqueIdentifier, getUniqueIdentifierForCucumber, isBrowserstackSession, isScreenshotCommand, o11yClassErrorHandler, pushDataToQueue, removeAnsiColors, sleep, uploadEventData } from './util.js';
|
|
5
5
|
import RequestQueueHandler from './request-handler.js';
|
|
6
6
|
import { DATA_SCREENSHOT_ENDPOINT, DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS, DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS } from './constants.js';
|
|
7
7
|
import { BStackLogger } from './bstackLogger.js';
|
|
@@ -757,23 +757,9 @@ class _InsightsHandler {
|
|
|
757
757
|
browser_version: this._platformMeta?.browserVersion,
|
|
758
758
|
platform: this._platformMeta?.platformName,
|
|
759
759
|
product: this._platformMeta?.product,
|
|
760
|
-
platform_version: this.
|
|
760
|
+
platform_version: getPlatformVersion(this._userCaps)
|
|
761
761
|
};
|
|
762
762
|
}
|
|
763
|
-
getPlatformVersion() {
|
|
764
|
-
const caps = this._userCaps;
|
|
765
|
-
const bstackOptions = this._userCaps?.['bstack:options'];
|
|
766
|
-
const keys = ['platformVersion', 'platform_version', 'osVersion', 'os_version'];
|
|
767
|
-
for (const key of keys) {
|
|
768
|
-
if (bstackOptions && bstackOptions?.[key]) {
|
|
769
|
-
return bstackOptions?.[key];
|
|
770
|
-
}
|
|
771
|
-
else if (caps[key]) {
|
|
772
|
-
return caps[key];
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
return null;
|
|
776
|
-
}
|
|
777
763
|
getIdentifier(test) {
|
|
778
764
|
if ('pickle' in test) {
|
|
779
765
|
return getUniqueIdentifierForCucumber(test);
|
package/build/launcher.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as BrowserstackLocalLauncher from 'browserstack-local';
|
|
2
2
|
import type { Capabilities, Services, Options } from '@wdio/types';
|
|
3
|
-
import type { BrowserstackConfig, App, AppConfig, AppUploadResponse } from './types.js';
|
|
3
|
+
import type { BrowserstackConfig, App, AppConfig, AppUploadResponse, UserConfig } from './types.js';
|
|
4
4
|
type BrowserstackLocal = BrowserstackLocalLauncher.Local & {
|
|
5
5
|
pid?: number;
|
|
6
|
-
stop(callback: (err?:
|
|
6
|
+
stop(callback: (err?: Error) => void): void;
|
|
7
7
|
};
|
|
8
8
|
export default class BrowserstackLauncherService implements Services.ServiceInstance {
|
|
9
9
|
private _options;
|
|
@@ -14,10 +14,15 @@ export default class BrowserstackLauncherService implements Services.ServiceInst
|
|
|
14
14
|
private _buildTag?;
|
|
15
15
|
private _buildIdentifier?;
|
|
16
16
|
private _accessibilityAutomation?;
|
|
17
|
+
private _percy?;
|
|
18
|
+
private _percyBestPlatformCaps?;
|
|
17
19
|
static _testOpsBuildStopped?: boolean;
|
|
18
20
|
constructor(_options: BrowserstackConfig & Options.Testrunner, capabilities: Capabilities.RemoteCapability, _config: Options.Testrunner);
|
|
21
|
+
onWorkerStart(cid: any, caps: any): Promise<void>;
|
|
19
22
|
onPrepare(config?: Options.Testrunner, capabilities?: Capabilities.RemoteCapabilities): Promise<unknown>;
|
|
20
23
|
onComplete(): Promise<unknown>;
|
|
24
|
+
setupPercy(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner, bsConfig: UserConfig): Promise<void>;
|
|
25
|
+
stopPercy(): Promise<void>;
|
|
21
26
|
_uploadApp(app: App): Promise<AppUploadResponse>;
|
|
22
27
|
/**
|
|
23
28
|
* @param {String | AppConfig} appConfig <string>: should be "app file path" or "app_url" or "custom_id" or "shareable_id".
|
package/build/launcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,yBAAyB,MAAM,oBAAoB,CAAA;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,yBAAyB,MAAM,oBAAoB,CAAA;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAKlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAyBnG,KAAK,iBAAiB,GAAG,yBAAyB,CAAC,KAAK,GAAG;IACvD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAA;CAC9C,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,2BAA4B,YAAW,QAAQ,CAAC,eAAe;IAY5E,OAAO,CAAC,QAAQ;IAEhB,OAAO,CAAC,OAAO;IAbnB,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,OAAO,CAAC,SAA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sB,CAAC,QAAQ,CAAC,EAAC,MAAM,EAAE,SAAS,CAAC,EAAC,MAAM,EAAE,eAAe,CAAC,EAAC,MAAM;IASnF,mBAAmB;CAQtB"}
|
package/build/launcher.js
CHANGED
|
@@ -9,10 +9,12 @@ import os from 'node:os';
|
|
|
9
9
|
import { SevereServiceError } from 'webdriverio';
|
|
10
10
|
import * as BrowserstackLocalLauncher from 'browserstack-local';
|
|
11
11
|
import PerformanceTester from './performance-tester.js';
|
|
12
|
+
import { startPercy, stopPercy, getBestPlatformForPercySnapshot } from './Percy/PercyHelper.js';
|
|
12
13
|
import { BSTACK_SERVICE_VERSION, NOT_ALLOWED_KEYS_IN_CAPS, VALID_APP_EXTENSION } from './constants.js';
|
|
13
|
-
import { launchTestSession, createAccessibilityTestRun, shouldAddServiceVersion, stopBuildUpstream, getCiInfo, isBStackSession, isUndefined, isAccessibilityAutomationSession, stopAccessibilityTestRun, isTrue, getBrowserStackUser, getBrowserStackKey, uploadLogs, setupExitHandlers } from './util.js';
|
|
14
|
+
import { launchTestSession, createAccessibilityTestRun, shouldAddServiceVersion, stopBuildUpstream, getCiInfo, isBStackSession, isUndefined, isAccessibilityAutomationSession, stopAccessibilityTestRun, isTrue, getBrowserStackUser, getBrowserStackKey, uploadLogs, ObjectsAreEqual, setupExitHandlers } from './util.js';
|
|
14
15
|
import CrashReporter from './crash-reporter.js';
|
|
15
16
|
import { BStackLogger } from './bstackLogger.js';
|
|
17
|
+
import { PercyLogger } from './Percy/PercyLogger.js';
|
|
16
18
|
import { FileStream } from './fileStream.js';
|
|
17
19
|
export default class BrowserstackLauncherService {
|
|
18
20
|
_options;
|
|
@@ -23,11 +25,14 @@ export default class BrowserstackLauncherService {
|
|
|
23
25
|
_buildTag;
|
|
24
26
|
_buildIdentifier;
|
|
25
27
|
_accessibilityAutomation;
|
|
28
|
+
_percy;
|
|
29
|
+
_percyBestPlatformCaps;
|
|
26
30
|
static _testOpsBuildStopped;
|
|
27
31
|
constructor(_options, capabilities, _config) {
|
|
28
32
|
this._options = _options;
|
|
29
33
|
this._config = _config;
|
|
30
34
|
BStackLogger.clearLogFile();
|
|
35
|
+
PercyLogger.clearLogFile();
|
|
31
36
|
setupExitHandlers();
|
|
32
37
|
// added to maintain backward compatibility with webdriverIO v5
|
|
33
38
|
this._config || (this._config = _options);
|
|
@@ -132,6 +137,19 @@ export default class BrowserstackLauncherService {
|
|
|
132
137
|
BStackLogger.error(`[Crash_Report_Upload] Config processing failed due to ${error}`);
|
|
133
138
|
}
|
|
134
139
|
}
|
|
140
|
+
async onWorkerStart(cid, caps) {
|
|
141
|
+
try {
|
|
142
|
+
if (this._options.percy && this._percyBestPlatformCaps) {
|
|
143
|
+
const isThisBestPercyPlatform = ObjectsAreEqual(caps, this._percyBestPlatformCaps);
|
|
144
|
+
if (isThisBestPercyPlatform) {
|
|
145
|
+
process.env.BEST_PLATFORM_CID = cid;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
PercyLogger.error(`Error while setting best platform for Percy snapshot at worker start ${err}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
135
153
|
async onPrepare(config, capabilities) {
|
|
136
154
|
/**
|
|
137
155
|
* Upload app to BrowserStack if valid file path to app is given.
|
|
@@ -217,6 +235,18 @@ export default class BrowserstackLauncherService {
|
|
|
217
235
|
buildIdentifier: this._buildIdentifier
|
|
218
236
|
});
|
|
219
237
|
}
|
|
238
|
+
if (this._options.percy) {
|
|
239
|
+
try {
|
|
240
|
+
const bestPlatformPercyCaps = getBestPlatformForPercySnapshot(capabilities);
|
|
241
|
+
this._percyBestPlatformCaps = bestPlatformPercyCaps;
|
|
242
|
+
await this.setupPercy(this._options, this._config, {
|
|
243
|
+
projectName: this._projectName
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
PercyLogger.error(`Error while setting up Percy ${err}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
220
250
|
if (!this._options.browserstackLocal) {
|
|
221
251
|
return BStackLogger.info('browserstackLocal is not enabled - skipping...');
|
|
222
252
|
}
|
|
@@ -288,6 +318,10 @@ export default class BrowserstackLauncherService {
|
|
|
288
318
|
BStackLogger.debug(`Failed to upload BrowserStack WDIO Service logs ${error}`);
|
|
289
319
|
}
|
|
290
320
|
BStackLogger.clearLogger();
|
|
321
|
+
if (this._options.percy) {
|
|
322
|
+
await this.stopPercy();
|
|
323
|
+
}
|
|
324
|
+
PercyLogger.clearLogger();
|
|
291
325
|
if (!this.browserstackLocal || !this.browserstackLocal.isRunning()) {
|
|
292
326
|
return;
|
|
293
327
|
}
|
|
@@ -316,6 +350,41 @@ export default class BrowserstackLauncherService {
|
|
|
316
350
|
return Promise.reject(err);
|
|
317
351
|
});
|
|
318
352
|
}
|
|
353
|
+
async setupPercy(options, config, bsConfig) {
|
|
354
|
+
if (this._percy?.isRunning()) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
this._percy = await startPercy(options, config, bsConfig);
|
|
359
|
+
if (!this._percy) {
|
|
360
|
+
throw new Error('Could not start percy, check percy logs for info.');
|
|
361
|
+
}
|
|
362
|
+
PercyLogger.info('Percy started successfully');
|
|
363
|
+
let signal = 0;
|
|
364
|
+
const handler = async () => {
|
|
365
|
+
signal++;
|
|
366
|
+
signal === 1 && await this.stopPercy();
|
|
367
|
+
};
|
|
368
|
+
process.on('beforeExit', handler);
|
|
369
|
+
process.on('SIGINT', handler);
|
|
370
|
+
process.on('SIGTERM', handler);
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
PercyLogger.debug(`Error in percy setup ${err}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async stopPercy() {
|
|
377
|
+
if (!this._percy || !this._percy.isRunning()) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
try {
|
|
381
|
+
await stopPercy(this._percy);
|
|
382
|
+
PercyLogger.info('Percy stopped');
|
|
383
|
+
}
|
|
384
|
+
catch (err) {
|
|
385
|
+
PercyLogger.error('Error occured while stopping percy : ' + err);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
319
388
|
async _uploadApp(app) {
|
|
320
389
|
BStackLogger.info(`uploading app ${app.app} ${app.customId ? `and custom_id: ${app.customId}` : ''} to browserstack`);
|
|
321
390
|
const form = new FormData();
|
package/build/reporter.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ declare class _TestReporter extends WDIOReporter {
|
|
|
15
15
|
private _gitConfigured;
|
|
16
16
|
private _currentHook;
|
|
17
17
|
private _currentTest;
|
|
18
|
+
private _userCaps?;
|
|
18
19
|
onRunnerStart(runnerStats: RunnerStats): Promise<void>;
|
|
20
|
+
private getUserCaps;
|
|
19
21
|
registerListeners(): void;
|
|
20
22
|
appendTestItemLog(stdLog: StdLog): Promise<void>;
|
|
21
23
|
setCurrentHook(hookDetails: CurrentRunInfo): void;
|
package/build/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAKzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExD,OAAO,KAAK,EAAgC,QAAQ,EAAc,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAKzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YA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C/E,KAAK,YAAY,GAAG,aAAa,CAAA;AACjC,eAAe,YAAY,CAAA"}
|
package/build/reporter.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import WDIOReporter from '@wdio/reporter';
|
|
3
3
|
import * as url from 'node:url';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import { getCloudProvider, uploadEventData, o11yClassErrorHandler, getGitMetaData, removeAnsiColors, getHookType, pushDataToQueue } from './util.js';
|
|
5
|
+
import { getCloudProvider, uploadEventData, o11yClassErrorHandler, getGitMetaData, removeAnsiColors, getHookType, pushDataToQueue, getPlatformVersion } from './util.js';
|
|
6
6
|
import RequestQueueHandler from './request-handler.js';
|
|
7
7
|
import { BStackLogger } from './bstackLogger.js';
|
|
8
8
|
class _TestReporter extends WDIOReporter {
|
|
@@ -18,8 +18,10 @@ class _TestReporter extends WDIOReporter {
|
|
|
18
18
|
_gitConfigured = false;
|
|
19
19
|
_currentHook = {};
|
|
20
20
|
_currentTest = {};
|
|
21
|
+
_userCaps = {};
|
|
21
22
|
async onRunnerStart(runnerStats) {
|
|
22
23
|
this._capabilities = runnerStats.capabilities;
|
|
24
|
+
this._userCaps = this.getUserCaps(runnerStats);
|
|
23
25
|
this._config = runnerStats.config;
|
|
24
26
|
this._sessionId = runnerStats.sessionId;
|
|
25
27
|
if (typeof this._config.testObservability !== 'undefined') {
|
|
@@ -28,6 +30,9 @@ class _TestReporter extends WDIOReporter {
|
|
|
28
30
|
await this.configureGit();
|
|
29
31
|
this.registerListeners();
|
|
30
32
|
}
|
|
33
|
+
getUserCaps(runnerStats) {
|
|
34
|
+
return runnerStats.instanceOptions[runnerStats.sessionId].capabilities;
|
|
35
|
+
}
|
|
31
36
|
registerListeners() {
|
|
32
37
|
if (this._config?.framework !== 'jasmine') {
|
|
33
38
|
return;
|
|
@@ -220,6 +225,7 @@ class _TestReporter extends WDIOReporter {
|
|
|
220
225
|
browser: this._capabilities?.browserName,
|
|
221
226
|
browser_version: this._capabilities?.browserVersion,
|
|
222
227
|
platform: this._capabilities?.platformName,
|
|
228
|
+
platform_version: getPlatformVersion(this._userCaps)
|
|
223
229
|
};
|
|
224
230
|
}
|
|
225
231
|
if (eventType === 'TestRunFinished' || eventType === 'HookRunFinished') {
|
package/build/service.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export default class BrowserstackService implements Services.ServiceInstance {
|
|
|
19
19
|
private _insightsHandler?;
|
|
20
20
|
private _accessibility;
|
|
21
21
|
private _accessibilityHandler?;
|
|
22
|
+
private _percy;
|
|
23
|
+
private _percyHandler?;
|
|
22
24
|
private _turboScale;
|
|
23
25
|
constructor(options: BrowserstackConfig & Options.Testrunner, _caps: Capabilities.RemoteCapability, _config: Options.Testrunner);
|
|
24
26
|
_updateCaps(fn: (caps: WebdriverIO.Capabilities | Capabilities.DesiredCapabilities) => void): void;
|
package/build/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAW9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAA8C,MAAM,YAAY,CAAA;AACnH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAW9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAA8C,MAAM,YAAY,CAAA;AACnH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,YAAY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ler from './accessibility-handler.js';
|
|
9
9
|
import { BStackLogger } from './bstackLogger.js';
|
|
10
|
+
import PercyHandler from './Percy/Percy-Handler.js';
|
|
10
11
|
export default class BrowserstackService {
|
|
11
12
|
_caps;
|
|
12
13
|
_config;
|
|
@@ -25,6 +26,8 @@ export default class BrowserstackService {
|
|
|
25
26
|
_insightsHandler;
|
|
26
27
|
_accessibility;
|
|
27
28
|
_accessibilityHandler;
|
|
29
|
+
_percy;
|
|
30
|
+
_percyHandler;
|
|
28
31
|
_turboScale;
|
|
29
32
|
constructor(options, _caps, _config) {
|
|
30
33
|
this._caps = _caps;
|
|
@@ -34,6 +37,7 @@ export default class BrowserstackService {
|
|
|
34
37
|
this._config || (this._config = this._options);
|
|
35
38
|
this._observability = this._options.testObservability;
|
|
36
39
|
this._accessibility = this._options.accessibility;
|
|
40
|
+
this._percy = this._options.percy;
|
|
37
41
|
this._turboScale = this._options.turboScale;
|
|
38
42
|
if (this._observability) {
|
|
39
43
|
this._config.reporters?.push(TestReporter);
|
|
@@ -50,6 +54,9 @@ export default class BrowserstackService {
|
|
|
50
54
|
if (strict) {
|
|
51
55
|
this._failureStatuses.push('pending');
|
|
52
56
|
}
|
|
57
|
+
if (process.env.WDIO_WORKER_ID === process.env.BEST_PLATFORM_CID) {
|
|
58
|
+
process.env.PERCY_SNAPSHOT = 'true';
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
_updateCaps(fn) {
|
|
55
62
|
const multiRemoteCap = this._caps;
|
|
@@ -83,24 +90,42 @@ export default class BrowserstackService {
|
|
|
83
90
|
this._sessionBaseUrl = 'https://api.browserstack.com/automate-turboscale/v1/sessions';
|
|
84
91
|
}
|
|
85
92
|
this._scenariosThatRan = [];
|
|
86
|
-
if (this.
|
|
87
|
-
|
|
93
|
+
if (this._browser) {
|
|
94
|
+
if (this._percy) {
|
|
95
|
+
this._percyHandler = new PercyHandler(this._options.percyCaptureMode, this._browser, this._caps, this._isAppAutomate(), this._config.framework);
|
|
96
|
+
this._percyHandler.before();
|
|
97
|
+
}
|
|
88
98
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
const sessionId = this._browser.sessionId;
|
|
100
|
+
if (this._observability) {
|
|
101
|
+
patchConsoleLogs();
|
|
102
|
+
this._insightsHandler = new InsightsHandler(this._browser, this._isAppAutomate(), this._config.framework, this._caps);
|
|
103
|
+
await this._insightsHandler.before();
|
|
104
|
+
}
|
|
91
105
|
/**
|
|
92
106
|
* register command event
|
|
93
107
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
108
|
+
this._browser.on('command', async (command) => {
|
|
109
|
+
if (this._observability) {
|
|
110
|
+
this._insightsHandler?.browserCommand('client:beforeCommand', Object.assign(command, { sessionId }), this._currentTest);
|
|
111
|
+
}
|
|
112
|
+
await this._percyHandler?.browserBeforeCommand(Object.assign(command, { sessionId }));
|
|
113
|
+
});
|
|
96
114
|
/**
|
|
97
115
|
* register result event
|
|
98
116
|
*/
|
|
99
|
-
this._browser.on('result', (result) =>
|
|
117
|
+
this._browser.on('result', (result) => {
|
|
118
|
+
if (this._observability) {
|
|
119
|
+
this._insightsHandler?.browserCommand('client:afterCommand', Object.assign(result, { sessionId }), this._currentTest);
|
|
120
|
+
}
|
|
121
|
+
this._percyHandler?.browserAfterCommand(Object.assign(result, { sessionId }));
|
|
122
|
+
});
|
|
100
123
|
}
|
|
101
124
|
catch (err) {
|
|
102
125
|
BStackLogger.error(`Error in service class before function: ${err}`);
|
|
103
|
-
|
|
126
|
+
if (this._observability) {
|
|
127
|
+
CrashReporter.uploadCrashReport(`Error in service class before function: ${err}`, err && err.stack);
|
|
128
|
+
}
|
|
104
129
|
}
|
|
105
130
|
}
|
|
106
131
|
if (this._browser && isBrowserstackSession(this._browser)) {
|
|
@@ -164,6 +189,7 @@ export default class BrowserstackService {
|
|
|
164
189
|
this._failReasons.push((error && error.message) || 'Unknown Error');
|
|
165
190
|
}
|
|
166
191
|
await this._insightsHandler?.afterTest(test, results);
|
|
192
|
+
await this._percyHandler?.afterTest();
|
|
167
193
|
await this._accessibilityHandler?.afterTest(this._suiteTitle, test);
|
|
168
194
|
}
|
|
169
195
|
async after(result) {
|
|
@@ -183,6 +209,7 @@ export default class BrowserstackService {
|
|
|
183
209
|
}
|
|
184
210
|
await this._insightsHandler?.uploadPending();
|
|
185
211
|
await this._insightsHandler?.teardown();
|
|
212
|
+
await this._percyHandler?.teardown();
|
|
186
213
|
if (process.env.BROWSERSTACK_O11Y_PERF_MEASUREMENT) {
|
|
187
214
|
await PerformanceTester.stopAndGenerate('performance-service.html');
|
|
188
215
|
PerformanceTester.calculateTimes([
|
|
@@ -227,6 +254,7 @@ export default class BrowserstackService {
|
|
|
227
254
|
this._failReasons.push(exception);
|
|
228
255
|
}
|
|
229
256
|
await this._insightsHandler?.afterScenario(world);
|
|
257
|
+
await this._percyHandler?.afterScenario();
|
|
230
258
|
await this._accessibilityHandler?.afterScenario(world);
|
|
231
259
|
}
|
|
232
260
|
async beforeStep(step, scenario) {
|
|
@@ -353,6 +381,7 @@ export default class BrowserstackService {
|
|
|
353
381
|
const post = !this._options.sessionNameOmitTestTitle ? ` - ${test.title}` : '';
|
|
354
382
|
name = `${pre}${test.parent}${post}`;
|
|
355
383
|
}
|
|
384
|
+
this._percyHandler?._setSessionName(name);
|
|
356
385
|
if (name !== this._fullTitle) {
|
|
357
386
|
this._fullTitle = name;
|
|
358
387
|
await this._updateJob({ name });
|
package/build/types.d.ts
CHANGED
|
@@ -51,6 +51,21 @@ export interface BrowserstackConfig {
|
|
|
51
51
|
* For e.g. buildName, projectName, BrowserStack access credentials, etc.
|
|
52
52
|
*/
|
|
53
53
|
testObservabilityOptions?: TestObservabilityOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Set this to true to enable BrowserStack Percy which will take screenshots
|
|
56
|
+
* and snapshots for your tests run on Browserstack
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
percy?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Accepts mode as a string to auto capture screenshots at different execution points
|
|
62
|
+
* Accepted values are auto, click, testcase, screenshot & manual
|
|
63
|
+
*/
|
|
64
|
+
percyCaptureMode?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Set the Percy related config options under this key.
|
|
67
|
+
*/
|
|
68
|
+
percyOptions?: any;
|
|
54
69
|
/**
|
|
55
70
|
* Set this to true to enable BrowserStack Accessibility Automation which will
|
|
56
71
|
* automically conduct accessibility testing on your pre-existing test builds
|
|
@@ -253,6 +268,7 @@ interface IntegrationObject {
|
|
|
253
268
|
browser_version?: string;
|
|
254
269
|
platform?: string;
|
|
255
270
|
product?: string;
|
|
271
|
+
platform_version?: string;
|
|
256
272
|
}
|
|
257
273
|
interface TestCodeBody {
|
|
258
274
|
lang: string;
|