@wdio/browserstack-service 7.32.4 → 7.33.0
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/accessibility-handler.d.ts +39 -0
- package/build/accessibility-handler.d.ts.map +1 -0
- package/build/accessibility-handler.js +258 -0
- package/build/constants.d.ts +3 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +6 -2
- package/build/cucumber-types.d.ts +17 -0
- package/build/cucumber-types.d.ts.map +1 -1
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -1
- package/build/insights-handler.d.ts +19 -3
- package/build/insights-handler.d.ts.map +1 -1
- package/build/insights-handler.js +274 -17
- package/build/launcher.d.ts +4 -0
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +152 -0
- package/build/log4jsAppender.d.ts +2 -0
- package/build/log4jsAppender.d.ts.map +1 -0
- package/build/log4jsAppender.js +26 -0
- package/build/logPatcher.d.ts +13 -0
- package/build/logPatcher.d.ts.map +1 -0
- package/build/logPatcher.js +43 -0
- package/build/logReportingAPI.d.ts +12 -0
- package/build/logReportingAPI.d.ts.map +1 -0
- package/build/logReportingAPI.js +61 -0
- package/build/reporter.d.ts +6 -1
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +42 -1
- package/build/scripts/test-event-scripts.d.ts +10 -0
- package/build/scripts/test-event-scripts.d.ts.map +1 -0
- package/build/scripts/test-event-scripts.js +73 -0
- package/build/service.d.ts +5 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +24 -4
- package/build/types.d.ts +34 -1
- package/build/types.d.ts.map +1 -1
- package/build/util.d.ts +32 -0
- package/build/util.d.ts.map +1 -1
- package/build/util.js +313 -2
- package/package.json +6 -5
package/build/util.d.ts
CHANGED
|
@@ -5,8 +5,10 @@ import https from 'https';
|
|
|
5
5
|
import type { Browser, MultiRemoteBrowser } from 'webdriverio';
|
|
6
6
|
import type { Capabilities, Frameworks, Options } from '@wdio/types';
|
|
7
7
|
import { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter';
|
|
8
|
+
import type { Method } from 'got';
|
|
8
9
|
import type { ITestCaseHookParameter } from './cucumber-types';
|
|
9
10
|
import { UploadType, BrowserstackConfig } from './types';
|
|
11
|
+
import RequestQueueHandler from './request-handler';
|
|
10
12
|
export declare const DEFAULT_REQUEST_CONFIG: {
|
|
11
13
|
agent: {
|
|
12
14
|
http: http.Agent;
|
|
@@ -35,6 +37,7 @@ export declare function getBrowserCapabilities(browser: Browser<'async'> | Multi
|
|
|
35
37
|
*/
|
|
36
38
|
export declare function isBrowserstackCapability(cap?: Capabilities.Capabilities): boolean;
|
|
37
39
|
export declare function getParentSuiteName(fullTitle: string, testSuiteTitle: string): string;
|
|
40
|
+
export declare function errorHandler(fn: Function): (...args: any) => any;
|
|
38
41
|
export declare function o11yErrorHandler(fn: Function): (...args: any) => any;
|
|
39
42
|
type ClassType = {
|
|
40
43
|
new (...args: any[]): any;
|
|
@@ -58,6 +61,7 @@ export declare function getCiInfo(): {
|
|
|
58
61
|
job_name: null;
|
|
59
62
|
build_number: string | undefined;
|
|
60
63
|
} | null;
|
|
64
|
+
export declare function nodeRequest(requestType: Method, apiEndpoint: string, options: any, apiUrl: string, timeout?: number): Promise<Object>;
|
|
61
65
|
export declare function getGitMetaData(): Promise<{
|
|
62
66
|
name?: undefined;
|
|
63
67
|
sha?: undefined;
|
|
@@ -119,6 +123,34 @@ export declare function getObservabilityProject(options: BrowserstackConfig & Op
|
|
|
119
123
|
export declare function getObservabilityBuild(options: BrowserstackConfig & Options.Testrunner, bstackBuildName?: string): string;
|
|
120
124
|
export declare function getObservabilityBuildTags(options: BrowserstackConfig & Options.Testrunner, bstackBuildTag?: string): string[];
|
|
121
125
|
export declare function frameworkSupportsHook(hook: string, framework?: string): boolean;
|
|
126
|
+
export declare function getFailureObject(error: string | Error): {
|
|
127
|
+
failure: {
|
|
128
|
+
backtrace: string[];
|
|
129
|
+
}[];
|
|
130
|
+
failure_reason: string;
|
|
131
|
+
failure_type: string | null;
|
|
132
|
+
};
|
|
133
|
+
export declare function patchConsoleLogs(): void;
|
|
122
134
|
export declare const sleep: (ms?: number) => Promise<unknown>;
|
|
135
|
+
export declare function pushDataToQueue(data: UploadType, requestQueueHandler?: RequestQueueHandler | undefined): Promise<void>;
|
|
136
|
+
export declare const validateCapsWithA11y: (deviceName?: any, platformMeta?: {
|
|
137
|
+
[key: string]: any;
|
|
138
|
+
} | undefined, chromeOptions?: any) => boolean;
|
|
139
|
+
export declare const shouldScanTestForAccessibility: (suiteTitle: string | undefined, testTitle: string, accessibilityOptions?: {
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
} | undefined) => boolean | undefined;
|
|
142
|
+
export declare const isAccessibilityAutomationSession: (accessibilityFlag?: boolean | string) => boolean | "" | undefined;
|
|
143
|
+
export declare const createAccessibilityTestRun: (...args: any) => any;
|
|
144
|
+
export declare const getA11yResults: (browser: any, isBrowserStackSession?: boolean, isAccessibility?: boolean | string) => Promise<{
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
}[]>;
|
|
147
|
+
export declare const getA11yResultsSummary: (browser: any, isBrowserStackSession?: boolean, isAccessibility?: boolean | string) => Promise<{
|
|
148
|
+
[key: string]: any;
|
|
149
|
+
}>;
|
|
150
|
+
export declare const stopAccessibilityTestRun: (...args: any) => any;
|
|
151
|
+
export declare function getBrowserStackUser(config: Options.Testrunner): string | undefined;
|
|
152
|
+
export declare function getBrowserStackKey(config: Options.Testrunner): string | undefined;
|
|
153
|
+
export declare function isUndefined(value: any): boolean;
|
|
154
|
+
export declare function isTrue(value?: any): boolean;
|
|
123
155
|
export {};
|
|
124
156
|
//# sourceMappingURL=util.d.ts.map
|
package/build/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AAC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function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.sleep = exports.frameworkSupportsHook = exports.getObservabilityBuildTags = exports.getObservabilityBuild = exports.getObservabilityProject = exports.getObservabilityKey = exports.getObservabilityUser = exports.batchAndPostEvents = exports.shouldAddServiceVersion = exports.isBStackSession = exports.isScreenshotCommand = exports.getHookType = exports.getHierarchy = exports.uploadEventData = exports.getLogTag = exports.removeAnsiColors = exports.getScenarioExamples = exports.isBrowserstackSession = exports.getCloudProvider = exports.getUniqueIdentifierForCucumber = exports.getUniqueIdentifier = exports.getGitMetaData = exports.getCiInfo = exports.stopBuildUpstream = exports.launchTestSession = exports.o11yClassErrorHandler = exports.o11yErrorHandler = exports.getParentSuiteName = exports.isBrowserstackCapability = exports.getBrowserCapabilities = exports.getBrowserDescription = exports.DEFAULT_REQUEST_CONFIG = void 0;
|
|
29
|
+
exports.isTrue = exports.isUndefined = exports.getBrowserStackKey = exports.getBrowserStackUser = exports.stopAccessibilityTestRun = exports.getA11yResultsSummary = exports.getA11yResults = exports.createAccessibilityTestRun = exports.isAccessibilityAutomationSession = exports.shouldScanTestForAccessibility = exports.validateCapsWithA11y = exports.pushDataToQueue = exports.sleep = exports.patchConsoleLogs = exports.getFailureObject = exports.frameworkSupportsHook = exports.getObservabilityBuildTags = exports.getObservabilityBuild = exports.getObservabilityProject = exports.getObservabilityKey = exports.getObservabilityUser = exports.batchAndPostEvents = exports.shouldAddServiceVersion = exports.isBStackSession = exports.isScreenshotCommand = exports.getHookType = exports.getHierarchy = exports.uploadEventData = exports.getLogTag = exports.removeAnsiColors = exports.getScenarioExamples = exports.isBrowserstackSession = exports.getCloudProvider = exports.getUniqueIdentifierForCucumber = exports.getUniqueIdentifier = exports.getGitMetaData = exports.nodeRequest = exports.getCiInfo = exports.stopBuildUpstream = exports.launchTestSession = exports.o11yClassErrorHandler = exports.o11yErrorHandler = exports.errorHandler = exports.getParentSuiteName = exports.isBrowserstackCapability = exports.getBrowserCapabilities = exports.getBrowserDescription = exports.DEFAULT_REQUEST_CONFIG = void 0;
|
|
30
30
|
const os_1 = require("os");
|
|
31
31
|
const util_1 = require("util");
|
|
32
32
|
const http_1 = __importDefault(require("http"));
|
|
@@ -38,9 +38,11 @@ const got_1 = __importStar(require("got"));
|
|
|
38
38
|
const git_repo_info_1 = __importDefault(require("git-repo-info"));
|
|
39
39
|
const gitconfiglocal_1 = __importDefault(require("gitconfiglocal"));
|
|
40
40
|
const crash_reporter_1 = __importDefault(require("./crash-reporter"));
|
|
41
|
+
const logPatcher_1 = __importDefault(require("./logPatcher"));
|
|
41
42
|
const constants_1 = require("./constants");
|
|
42
43
|
const request_handler_1 = __importDefault(require("./request-handler"));
|
|
43
44
|
const performance_tester_1 = __importDefault(require("./performance-tester"));
|
|
45
|
+
const test_event_scripts_1 = require("./scripts/test-event-scripts");
|
|
44
46
|
const pGitconfig = (0, util_1.promisify)(gitconfiglocal_1.default);
|
|
45
47
|
const log = (0, logger_1.default)('@wdio/browserstack-service');
|
|
46
48
|
exports.DEFAULT_REQUEST_CONFIG = {
|
|
@@ -123,6 +125,22 @@ function processError(error, fn, args) {
|
|
|
123
125
|
}
|
|
124
126
|
crash_reporter_1.default.uploadCrashReport(`Error in executing ${fn.name} with args ${argsString} : ${error}`, error && error.stack);
|
|
125
127
|
}
|
|
128
|
+
function errorHandler(fn) {
|
|
129
|
+
return function (...args) {
|
|
130
|
+
try {
|
|
131
|
+
const functionToHandle = fn;
|
|
132
|
+
const result = functionToHandle(...args);
|
|
133
|
+
if (result instanceof Promise) {
|
|
134
|
+
return result.catch(error => log.error(`Error in executing ${fn.name} with args ${args}: ${error}`));
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
log.error(`Error in executing ${fn.name} with args ${args}: ${error}`);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
exports.errorHandler = errorHandler;
|
|
126
144
|
function o11yErrorHandler(fn) {
|
|
127
145
|
return function (...args) {
|
|
128
146
|
try {
|
|
@@ -379,12 +397,42 @@ function getCiInfo() {
|
|
|
379
397
|
return null;
|
|
380
398
|
}
|
|
381
399
|
exports.getCiInfo = getCiInfo;
|
|
400
|
+
async function nodeRequest(requestType, apiEndpoint, options, apiUrl, timeout = 120000) {
|
|
401
|
+
try {
|
|
402
|
+
const response = await (0, got_1.default)(`${apiUrl}/${apiEndpoint}`, {
|
|
403
|
+
method: requestType,
|
|
404
|
+
timeout: {
|
|
405
|
+
request: timeout
|
|
406
|
+
},
|
|
407
|
+
...options
|
|
408
|
+
}).json();
|
|
409
|
+
return response;
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
if (error instanceof got_1.HTTPError && error.response) {
|
|
413
|
+
const errorMessageJson = error.response.body ? JSON.parse(error.response.body.toString()) : null;
|
|
414
|
+
const errorMessage = errorMessageJson ? errorMessageJson.message : null;
|
|
415
|
+
if (errorMessage) {
|
|
416
|
+
log.error(`${errorMessage} - ${error.stack}`);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
log.error(`${error.stack}`);
|
|
420
|
+
}
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
log.error(`Failed to fire api request due to ${error} - ${error.stack}`);
|
|
425
|
+
throw error;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
exports.nodeRequest = nodeRequest;
|
|
382
430
|
async function getGitMetaData() {
|
|
383
431
|
var info = (0, git_repo_info_1.default)();
|
|
384
432
|
if (!info.commonGitDir)
|
|
385
433
|
return {};
|
|
386
434
|
const { remote } = await pGitconfig(info.commonGitDir);
|
|
387
|
-
const remotes = Object.keys(remote).map(remoteName => ({ name: remoteName, url: remote[remoteName]['url'] }));
|
|
435
|
+
const remotes = remote ? Object.keys(remote).map(remoteName => ({ name: remoteName, url: remote[remoteName]['url'] })) : [];
|
|
388
436
|
return {
|
|
389
437
|
name: 'git',
|
|
390
438
|
sha: info.sha,
|
|
@@ -649,8 +697,271 @@ function frameworkSupportsHook(hook, framework) {
|
|
|
649
697
|
if (framework === 'mocha' && (hook === 'before' || hook === 'after' || hook === 'beforeEach' || hook === 'afterEach')) {
|
|
650
698
|
return true;
|
|
651
699
|
}
|
|
700
|
+
if (framework === 'cucumber') {
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
652
703
|
return false;
|
|
653
704
|
}
|
|
654
705
|
exports.frameworkSupportsHook = frameworkSupportsHook;
|
|
706
|
+
function getFailureObject(error) {
|
|
707
|
+
const stack = error.stack;
|
|
708
|
+
const message = typeof error === 'string' ? error : error.message;
|
|
709
|
+
const backtrace = stack ? removeAnsiColors(stack.toString()) : '';
|
|
710
|
+
return {
|
|
711
|
+
failure: [{ backtrace: [backtrace] }],
|
|
712
|
+
failure_reason: removeAnsiColors(message.toString()),
|
|
713
|
+
failure_type: message ? (message.toString().match(/AssertionError/) ? 'AssertionError' : 'UnhandledError') : null
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
exports.getFailureObject = getFailureObject;
|
|
717
|
+
function patchConsoleLogs() {
|
|
718
|
+
const BSTestOpsPatcher = new logPatcher_1.default({});
|
|
719
|
+
Object.keys(constants_1.consoleHolder).forEach((method) => {
|
|
720
|
+
const origMethod = console[method].bind(console);
|
|
721
|
+
// Make sure we don't override Constructors
|
|
722
|
+
// Arrow functions are not construable
|
|
723
|
+
if (typeof console[method] === 'function'
|
|
724
|
+
&& method !== 'Console') {
|
|
725
|
+
console[method] = (...args) => {
|
|
726
|
+
origMethod(...args);
|
|
727
|
+
BSTestOpsPatcher[method](...args);
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
exports.patchConsoleLogs = patchConsoleLogs;
|
|
655
733
|
const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
656
734
|
exports.sleep = sleep;
|
|
735
|
+
async function pushDataToQueue(data, requestQueueHandler = undefined) {
|
|
736
|
+
if (!requestQueueHandler) {
|
|
737
|
+
requestQueueHandler = request_handler_1.default.getInstance();
|
|
738
|
+
}
|
|
739
|
+
const req = requestQueueHandler.add(data);
|
|
740
|
+
if (req.proceed && req.data) {
|
|
741
|
+
await uploadEventData(req.data, req.url);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
exports.pushDataToQueue = pushDataToQueue;
|
|
745
|
+
const validateCapsWithA11y = (deviceName, platformMeta, chromeOptions) => {
|
|
746
|
+
var _a, _b;
|
|
747
|
+
try {
|
|
748
|
+
if (deviceName) {
|
|
749
|
+
log.warn('Accessibility Automation will run only on Desktop browsers.');
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
if (((_a = platformMeta === null || platformMeta === void 0 ? void 0 : platformMeta.browser_name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'chrome') {
|
|
753
|
+
log.warn('Accessibility Automation will run only on Chrome browsers.');
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
const browserVersion = platformMeta === null || platformMeta === void 0 ? void 0 : platformMeta.browser_version;
|
|
757
|
+
if (!isUndefined(browserVersion) && !(browserVersion === 'latest' || parseFloat(browserVersion + '') > 94)) {
|
|
758
|
+
log.warn('Accessibility Automation will run only on Chrome browser version greater than 94.');
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
if ((_b = chromeOptions === null || chromeOptions === void 0 ? void 0 : chromeOptions.args) === null || _b === void 0 ? void 0 : _b.includes('--headless')) {
|
|
762
|
+
log.warn('Accessibility Automation will not run on legacy headless mode. Switch to new headless mode or avoid using headless mode.');
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
catch (error) {
|
|
768
|
+
log.debug(`Exception in checking capabilities compatibility with Accessibility. Error: ${error}`);
|
|
769
|
+
}
|
|
770
|
+
return false;
|
|
771
|
+
};
|
|
772
|
+
exports.validateCapsWithA11y = validateCapsWithA11y;
|
|
773
|
+
const shouldScanTestForAccessibility = (suiteTitle, testTitle, accessibilityOptions) => {
|
|
774
|
+
try {
|
|
775
|
+
const includeTags = Array.isArray(accessibilityOptions === null || accessibilityOptions === void 0 ? void 0 : accessibilityOptions.includeTagsInTestingScope) ? accessibilityOptions === null || accessibilityOptions === void 0 ? void 0 : accessibilityOptions.includeTagsInTestingScope : [];
|
|
776
|
+
const excludeTags = Array.isArray(accessibilityOptions === null || accessibilityOptions === void 0 ? void 0 : accessibilityOptions.excludeTagsInTestingScope) ? accessibilityOptions === null || accessibilityOptions === void 0 ? void 0 : accessibilityOptions.excludeTagsInTestingScope : [];
|
|
777
|
+
const fullTestName = suiteTitle + ' ' + testTitle;
|
|
778
|
+
const excluded = excludeTags === null || excludeTags === void 0 ? void 0 : excludeTags.some((exclude) => fullTestName.includes(exclude));
|
|
779
|
+
const included = (includeTags === null || includeTags === void 0 ? void 0 : includeTags.length) === 0 || (includeTags === null || includeTags === void 0 ? void 0 : includeTags.some((include) => fullTestName.includes(include)));
|
|
780
|
+
return !excluded && included;
|
|
781
|
+
}
|
|
782
|
+
catch (error) {
|
|
783
|
+
log.debug('Error while validating test case for accessibility before scanning. Error : ', error);
|
|
784
|
+
}
|
|
785
|
+
return false;
|
|
786
|
+
};
|
|
787
|
+
exports.shouldScanTestForAccessibility = shouldScanTestForAccessibility;
|
|
788
|
+
const isAccessibilityAutomationSession = (accessibilityFlag) => {
|
|
789
|
+
try {
|
|
790
|
+
const hasA11yJwtToken = typeof process.env.BSTACK_A11Y_JWT === 'string' && process.env.BSTACK_A11Y_JWT.length > 0 && process.env.BSTACK_A11Y_JWT !== 'null' && process.env.BSTACK_A11Y_JWT !== 'undefined';
|
|
791
|
+
return accessibilityFlag && hasA11yJwtToken;
|
|
792
|
+
}
|
|
793
|
+
catch (error) {
|
|
794
|
+
log.debug(`Exception in verifying the Accessibility session with error : ${error}`);
|
|
795
|
+
}
|
|
796
|
+
return false;
|
|
797
|
+
};
|
|
798
|
+
exports.isAccessibilityAutomationSession = isAccessibilityAutomationSession;
|
|
799
|
+
exports.createAccessibilityTestRun = errorHandler(async function createAccessibilityTestRun(options, config, bsConfig) {
|
|
800
|
+
const userName = getBrowserStackUser(config);
|
|
801
|
+
const accessKey = getBrowserStackKey(config);
|
|
802
|
+
if (isUndefined(userName) || isUndefined(accessKey)) {
|
|
803
|
+
log.error('Exception while creating test run for BrowserStack Accessibility Automation: Missing BrowserStack credentials');
|
|
804
|
+
return null;
|
|
805
|
+
}
|
|
806
|
+
const data = {
|
|
807
|
+
'projectName': bsConfig.projectName,
|
|
808
|
+
'buildName': bsConfig.buildName ||
|
|
809
|
+
path_1.default.basename(path_1.default.resolve(process.cwd())),
|
|
810
|
+
'startTime': (new Date()).toISOString(),
|
|
811
|
+
'description': '',
|
|
812
|
+
'source': {
|
|
813
|
+
frameworkName: 'WebdriverIO-' + config.framework,
|
|
814
|
+
frameworkVersion: bsConfig.bstackServiceVersion,
|
|
815
|
+
sdkVersion: bsConfig.bstackServiceVersion
|
|
816
|
+
},
|
|
817
|
+
'settings': bsConfig.accessibilityOptions || {},
|
|
818
|
+
'versionControl': await getGitMetaData(),
|
|
819
|
+
'ciInfo': getCiInfo(),
|
|
820
|
+
'hostInfo': {
|
|
821
|
+
hostname: (0, os_1.hostname)(),
|
|
822
|
+
platform: (0, os_1.platform)(),
|
|
823
|
+
type: (0, os_1.type)(),
|
|
824
|
+
version: (0, os_1.version)(),
|
|
825
|
+
arch: (0, os_1.arch)()
|
|
826
|
+
},
|
|
827
|
+
'browserstackAutomation': true,
|
|
828
|
+
};
|
|
829
|
+
const requestOptions = {
|
|
830
|
+
json: data,
|
|
831
|
+
username: getBrowserStackUser(config),
|
|
832
|
+
password: getBrowserStackKey(config),
|
|
833
|
+
};
|
|
834
|
+
try {
|
|
835
|
+
const response = await nodeRequest('POST', 'test_runs', requestOptions, constants_1.ACCESSIBILITY_API_URL);
|
|
836
|
+
log.debug(`[Create Accessibility Test Run] Success response: ${JSON.stringify(response)}`);
|
|
837
|
+
if (response.data.accessibilityToken) {
|
|
838
|
+
process.env.BSTACK_A11Y_JWT = response.data.accessibilityToken;
|
|
839
|
+
}
|
|
840
|
+
if (response.data.id) {
|
|
841
|
+
process.env.BS_A11Y_TEST_RUN_ID = response.data.id;
|
|
842
|
+
}
|
|
843
|
+
log.debug(`BrowserStack Accessibility Automation Test Run ID: ${response.data.id}`);
|
|
844
|
+
return response.data.scannerVersion;
|
|
845
|
+
}
|
|
846
|
+
catch (error) {
|
|
847
|
+
if (error.response) {
|
|
848
|
+
log.error(`Exception while creating test run for BrowserStack Accessibility Automation: ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
const errorMessage = error.message;
|
|
852
|
+
if (errorMessage === 'Invalid configuration passed.') {
|
|
853
|
+
log.error(`Exception while creating test run for BrowserStack Accessibility Automation: ${errorMessage || error.stack}`);
|
|
854
|
+
for (const errorkey of error.errors) {
|
|
855
|
+
log.error(errorkey.message);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
else {
|
|
859
|
+
log.error(`Exception while creating test run for BrowserStack Accessibility Automation: ${errorMessage || error.stack}`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
const getA11yResults = async (browser, isBrowserStackSession, isAccessibility) => {
|
|
866
|
+
if (!isBrowserStackSession) {
|
|
867
|
+
log.warn('Not a BrowserStack Automate session, cannot retrieve Accessibility results.');
|
|
868
|
+
return []; // since we are running only on Automate as of now
|
|
869
|
+
}
|
|
870
|
+
if (!(0, exports.isAccessibilityAutomationSession)(isAccessibility)) {
|
|
871
|
+
log.warn('Not an Accessibility Automation session, cannot retrieve Accessibility results.');
|
|
872
|
+
return [];
|
|
873
|
+
}
|
|
874
|
+
try {
|
|
875
|
+
const results = await browser.execute(test_event_scripts_1.accessibilityResults);
|
|
876
|
+
return results;
|
|
877
|
+
}
|
|
878
|
+
catch {
|
|
879
|
+
log.error('No accessibility results were found.');
|
|
880
|
+
return [];
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
exports.getA11yResults = getA11yResults;
|
|
884
|
+
const getA11yResultsSummary = async (browser, isBrowserStackSession, isAccessibility) => {
|
|
885
|
+
if (!isBrowserStackSession) {
|
|
886
|
+
return {}; // since we are running only on Automate as of now
|
|
887
|
+
}
|
|
888
|
+
if (!(0, exports.isAccessibilityAutomationSession)(isAccessibility)) {
|
|
889
|
+
log.warn('Not an Accessibility Automation session, cannot retrieve Accessibility results summary.');
|
|
890
|
+
return {};
|
|
891
|
+
}
|
|
892
|
+
try {
|
|
893
|
+
const summaryResults = await browser.execute(test_event_scripts_1.accessibilityResultsSummary);
|
|
894
|
+
return summaryResults;
|
|
895
|
+
}
|
|
896
|
+
catch {
|
|
897
|
+
log.error('No accessibility summary was found.');
|
|
898
|
+
return {};
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
exports.getA11yResultsSummary = getA11yResultsSummary;
|
|
902
|
+
exports.stopAccessibilityTestRun = errorHandler(async function stopAccessibilityTestRun() {
|
|
903
|
+
const hasA11yJwtToken = typeof process.env.BSTACK_A11Y_JWT === 'string' && process.env.BSTACK_A11Y_JWT.length > 0 && process.env.BSTACK_A11Y_JWT !== 'null' && process.env.BSTACK_A11Y_JWT !== 'undefined';
|
|
904
|
+
if (!hasA11yJwtToken) {
|
|
905
|
+
return {
|
|
906
|
+
status: 'error',
|
|
907
|
+
message: 'Build creation had failed.'
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
const data = {
|
|
911
|
+
'endTime': (new Date()).toISOString(),
|
|
912
|
+
};
|
|
913
|
+
const requestOptions = { ...{
|
|
914
|
+
json: data,
|
|
915
|
+
headers: {
|
|
916
|
+
'Authorization': `Bearer ${process.env.BSTACK_A11Y_JWT}`,
|
|
917
|
+
}
|
|
918
|
+
} };
|
|
919
|
+
try {
|
|
920
|
+
const response = await nodeRequest('PUT', 'test_runs/stop', requestOptions, constants_1.ACCESSIBILITY_API_URL);
|
|
921
|
+
if (response.data && response.data.error) {
|
|
922
|
+
throw new Error('Invalid request: ' + response.data.error);
|
|
923
|
+
}
|
|
924
|
+
else if (response.error) {
|
|
925
|
+
throw new Error('Invalid request: ' + response.error);
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
log.info(`BrowserStack Accessibility Automation Test Run marked as completed at ${new Date().toISOString()}`);
|
|
929
|
+
return { status: 'success', message: '' };
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
catch (error) {
|
|
933
|
+
if (error.response && error.response.status && error.response.statusText && error.response.data) {
|
|
934
|
+
log.error(`Exception while marking completion of BrowserStack Accessibility Automation Test Run: ${error.response.status} ${error.response.statusText} ${JSON.stringify(error.response.data)}`);
|
|
935
|
+
}
|
|
936
|
+
else {
|
|
937
|
+
log.error(`Exception while marking completion of BrowserStack Accessibility Automation Test Run: ${error.message || util_2.default.format(error)}`);
|
|
938
|
+
}
|
|
939
|
+
return {
|
|
940
|
+
status: 'error',
|
|
941
|
+
message: error.message ||
|
|
942
|
+
(error.response ? `${error.response.status}:${error.response.statusText}` : error)
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
function getBrowserStackUser(config) {
|
|
947
|
+
if (process.env.BROWSERSTACK_USERNAME) {
|
|
948
|
+
return process.env.BROWSERSTACK_USERNAME;
|
|
949
|
+
}
|
|
950
|
+
return config.user;
|
|
951
|
+
}
|
|
952
|
+
exports.getBrowserStackUser = getBrowserStackUser;
|
|
953
|
+
function getBrowserStackKey(config) {
|
|
954
|
+
if (process.env.BROWSERSTACK_ACCESS_KEY) {
|
|
955
|
+
return process.env.BROWSERSTACK_ACCESS_KEY;
|
|
956
|
+
}
|
|
957
|
+
return config.key;
|
|
958
|
+
}
|
|
959
|
+
exports.getBrowserStackKey = getBrowserStackKey;
|
|
960
|
+
function isUndefined(value) {
|
|
961
|
+
return value === undefined || value === null;
|
|
962
|
+
}
|
|
963
|
+
exports.isUndefined = isUndefined;
|
|
964
|
+
function isTrue(value) {
|
|
965
|
+
return (value + '') === 'true';
|
|
966
|
+
}
|
|
967
|
+
exports.isTrue = isTrue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/browserstack-service",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.33.0",
|
|
4
4
|
"description": "WebdriverIO service for better Browserstack integration",
|
|
5
5
|
"author": "Adam Bjerstedt <abjerstedt@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browserstack-service",
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
"@types/gitconfiglocal": "^2.0.1",
|
|
27
27
|
"@wdio/logger": "7.26.0",
|
|
28
28
|
"@wdio/reporter": "7.25.4",
|
|
29
|
-
"@wdio/types": "7.
|
|
29
|
+
"@wdio/types": "7.33.0",
|
|
30
30
|
"browserstack-local": "^1.4.5",
|
|
31
31
|
"csv-writer": "^1.6.0",
|
|
32
32
|
"form-data": "^4.0.0",
|
|
33
33
|
"git-repo-info": "^2.1.1",
|
|
34
34
|
"gitconfiglocal": "^2.1.0",
|
|
35
35
|
"got": "^11.0.2",
|
|
36
|
-
"uuid": "^
|
|
37
|
-
"webdriverio": "7.
|
|
36
|
+
"uuid": "^9.0.1",
|
|
37
|
+
"webdriverio": "7.33.0",
|
|
38
|
+
"winston-transport": "^4.5.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@wdio/cli": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"access": "public"
|
|
44
45
|
},
|
|
45
46
|
"types": "./build/index.d.ts",
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "dddde783069dffb85594717ae92415d67ef9ce6b"
|
|
47
48
|
}
|