browserstack-cypress-cli 1.31.10 → 1.32.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/bin/accessibility-automation/cypress/index.js +274 -276
- package/bin/accessibility-automation/helper.js +41 -27
- package/bin/accessibility-automation/plugin/index.js +2 -3
- package/bin/commands/generateReport.js +0 -1
- package/bin/commands/info.js +39 -38
- package/bin/commands/runs.js +7 -9
- package/bin/commands/stop.js +0 -1
- package/bin/helpers/atsHelper.js +48 -39
- package/bin/helpers/build.js +39 -31
- package/bin/helpers/buildArtifacts.js +87 -69
- package/bin/helpers/capabilityHelper.js +1 -0
- package/bin/helpers/checkUploaded.js +43 -33
- package/bin/helpers/downloadBuildStacktrace.js +23 -14
- package/bin/helpers/getInitialDetails.js +33 -22
- package/bin/helpers/helper.js +10 -2
- package/bin/helpers/reporterHTML.js +52 -39
- package/bin/helpers/sync/syncSpecsLogs.js +36 -23
- package/bin/helpers/usageReporting.js +52 -34
- package/bin/helpers/utils.js +96 -77
- package/bin/helpers/zipUpload.js +61 -85
- package/bin/testObservability/crashReporter/index.js +23 -14
- package/bin/testObservability/cypress/index.js +7 -7
- package/bin/testObservability/helper/helper.js +59 -43
- package/bin/testObservability/helper/requestQueueHandler.js +2 -2
- package/bin/testObservability/plugin/ipcServer.js +6 -6
- package/bin/testObservability/reporter/index.js +8 -10
- package/package.json +5 -4
|
@@ -3,12 +3,14 @@ const { API_URL } = require('./constants');
|
|
|
3
3
|
const utils = require('../helpers/utils');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const
|
|
6
|
+
const axios = require('axios');
|
|
7
7
|
const os = require('os');
|
|
8
8
|
const glob = require('glob');
|
|
9
9
|
const helper = require('../helpers/helper');
|
|
10
10
|
const { CYPRESS_V10_AND_ABOVE_CONFIG_FILE_EXTENSIONS } = require('../helpers/constants');
|
|
11
|
+
const { consoleHolder } = require("../testObservability/helper/constants");
|
|
11
12
|
const supportFileContentMap = {}
|
|
13
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
|
12
14
|
|
|
13
15
|
exports.checkAccessibilityPlatform = (user_config) => {
|
|
14
16
|
let accessibility = false;
|
|
@@ -86,8 +88,8 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
86
88
|
|
|
87
89
|
const config = {
|
|
88
90
|
auth: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
username: userName,
|
|
92
|
+
password: accessKey
|
|
91
93
|
},
|
|
92
94
|
headers: {
|
|
93
95
|
'Content-Type': 'application/json'
|
|
@@ -105,12 +107,13 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
105
107
|
process.env.BROWSERSTACK_TEST_ACCESSIBILITY = 'true';
|
|
106
108
|
}
|
|
107
109
|
logger.debug(`BrowserStack Accessibility Automation Test Run ID: ${response.data.data.id}`);
|
|
108
|
-
|
|
110
|
+
|
|
109
111
|
this.setAccessibilityCypressCapabilities(user_config, response.data);
|
|
110
112
|
helper.setBrowserstackCypressCliDependency(user_config);
|
|
111
113
|
|
|
112
114
|
} catch (error) {
|
|
113
115
|
if (error.response) {
|
|
116
|
+
logger.error("Incorrect Cred")
|
|
114
117
|
logger.error(
|
|
115
118
|
`Exception while creating test run for BrowserStack Accessibility Automation: ${
|
|
116
119
|
error.response.status
|
|
@@ -118,6 +121,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
118
121
|
);
|
|
119
122
|
} else {
|
|
120
123
|
if(error.message === 'Invalid configuration passed.') {
|
|
124
|
+
logger.error("Invalid configuration passed.")
|
|
121
125
|
logger.error(
|
|
122
126
|
`Exception while creating test run for BrowserStack Accessibility Automation: ${
|
|
123
127
|
error.message || error.stack
|
|
@@ -126,7 +130,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
126
130
|
for(const errorkey of error.errors){
|
|
127
131
|
logger.error(errorkey.message);
|
|
128
132
|
}
|
|
129
|
-
|
|
133
|
+
|
|
130
134
|
} else {
|
|
131
135
|
logger.error(
|
|
132
136
|
`Exception while creating test run for BrowserStack Accessibility Automation: ${
|
|
@@ -143,33 +147,43 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
143
147
|
|
|
144
148
|
const nodeRequest = (type, url, data, config) => {
|
|
145
149
|
return new Promise(async (resolve, reject) => {
|
|
146
|
-
const options = {
|
|
150
|
+
const options = {
|
|
151
|
+
...config,
|
|
147
152
|
method: type,
|
|
148
153
|
url: `${API_URL}/${url}`,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}};
|
|
154
|
+
data: data
|
|
155
|
+
};
|
|
152
156
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
if(process.env.HTTP_PROXY){
|
|
158
|
+
options.proxy = false
|
|
159
|
+
options.httpsAgent = new HttpsProxyAgent(process.env.HTTP_PROXY);
|
|
160
|
+
|
|
161
|
+
} else if (process.env.HTTPS_PROXY){
|
|
162
|
+
options.proxy = false
|
|
163
|
+
options.httpsAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
axios(options).then(response => {
|
|
167
|
+
if(!(response.status == 201 || response.status == 200)) {
|
|
168
|
+
logger.info("response.status in nodeRequest", response.status);
|
|
169
|
+
reject(response && response.data ? response.data : `Received response from BrowserStack Server with status : ${response.status}`);
|
|
160
170
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
try {
|
|
172
|
+
if(typeof(response.data) !== 'object') body = JSON.parse(response.data);
|
|
173
|
+
} catch(e) {
|
|
174
|
+
if(!url.includes('/stop')) {
|
|
175
|
+
reject('Not a JSON response from BrowserStack Server');
|
|
176
|
+
}
|
|
166
177
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
178
|
+
resolve({
|
|
179
|
+
data: response.data
|
|
180
|
+
});
|
|
171
181
|
}
|
|
172
|
-
})
|
|
182
|
+
}).catch(error => {
|
|
183
|
+
|
|
184
|
+
logger.info("error in nodeRequest", error);
|
|
185
|
+
reject(error);
|
|
186
|
+
})
|
|
173
187
|
});
|
|
174
188
|
}
|
|
175
189
|
|
|
@@ -211,7 +225,7 @@ exports.setAccessibilityEventListeners = (bsConfig) => {
|
|
|
211
225
|
try {
|
|
212
226
|
if(!file.includes('commands.js') && !file.includes('commands.ts')) {
|
|
213
227
|
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
|
|
214
|
-
|
|
228
|
+
|
|
215
229
|
let cypressCommandEventListener = getAccessibilityCypressCommandEventListener(path.extname(file));
|
|
216
230
|
if(!defaultFileContent.includes(cypressCommandEventListener)) {
|
|
217
231
|
let newFileContent = defaultFileContent +
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
const path = require("node:path");
|
|
3
2
|
|
|
4
3
|
const browserstackAccessibility = (on, config) => {
|
|
@@ -10,7 +9,7 @@ const browserstackAccessibility = (on, config) => {
|
|
|
10
9
|
on('task', {
|
|
11
10
|
browserstack_log(message) {
|
|
12
11
|
console.log(message)
|
|
13
|
-
|
|
12
|
+
|
|
14
13
|
return null
|
|
15
14
|
},
|
|
16
15
|
})
|
|
@@ -36,7 +35,7 @@ const browserstackAccessibility = (on, config) => {
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
} catch(err) {}
|
|
39
|
-
|
|
38
|
+
|
|
40
39
|
})
|
|
41
40
|
config.env.ACCESSIBILITY_EXTENSION_PATH = process.env.ACCESSIBILITY_EXTENSION_PATH
|
|
42
41
|
config.env.OS_VERSION = process.env.OS_VERSION
|
|
@@ -31,7 +31,6 @@ module.exports = function generateReport(args, rawArgs) {
|
|
|
31
31
|
let messageType = Constants.messageTypes.INFO;
|
|
32
32
|
let errorCode = null;
|
|
33
33
|
let buildId = args._[1];
|
|
34
|
-
|
|
35
34
|
reportGenerator(bsConfig, buildId, args, rawArgs, buildReportData);
|
|
36
35
|
utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, buildReportData, rawArgs);
|
|
37
36
|
} catch(err) {
|
package/bin/commands/info.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const
|
|
3
|
-
|
|
2
|
+
const axios = require('axios').default;
|
|
4
3
|
const config = require("../helpers/config"),
|
|
5
4
|
logger = require("../helpers/logger").winstonLogger,
|
|
6
5
|
Constants = require("../helpers/constants"),
|
|
7
6
|
utils = require("../helpers/utils"),
|
|
8
7
|
getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails;
|
|
9
8
|
|
|
9
|
+
const { setAxiosProxy } = require('../helpers/helper');
|
|
10
|
+
|
|
10
11
|
module.exports = function info(args, rawArgs) {
|
|
11
12
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
12
13
|
|
|
@@ -19,7 +20,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
19
20
|
// accept the access key from command line if provided
|
|
20
21
|
utils.setAccessKey(bsConfig, args);
|
|
21
22
|
|
|
22
|
-
getInitialDetails(bsConfig, args, rawArgs).then((buildReportData) => {
|
|
23
|
+
getInitialDetails(bsConfig, args, rawArgs).then(async (buildReportData) => {
|
|
23
24
|
|
|
24
25
|
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
|
|
25
26
|
|
|
@@ -43,53 +44,46 @@ module.exports = function info(args, rawArgs) {
|
|
|
43
44
|
options.url = `${config.turboScaleBuildsUrl}/${buildId}`;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
let message = null;
|
|
48
|
+
let messageType = null;
|
|
49
|
+
let errorCode = null;
|
|
50
|
+
|
|
51
|
+
options.config = {
|
|
52
|
+
auth: {
|
|
53
|
+
username: bsConfig.auth.username,
|
|
54
|
+
password: bsConfig.auth.access_key
|
|
55
|
+
},
|
|
56
|
+
headers: options.headers
|
|
57
|
+
};
|
|
58
|
+
setAxiosProxy(options.config);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const response = await axios.get(options.url, options.config);
|
|
62
|
+
let build = null;
|
|
60
63
|
try {
|
|
61
|
-
build =
|
|
64
|
+
build = response.data;
|
|
62
65
|
} catch (error) {
|
|
63
66
|
build = null;
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
if (resp.statusCode == 299) {
|
|
68
|
+
if (response.status == 299) {
|
|
67
69
|
messageType = Constants.messageTypes.INFO;
|
|
68
70
|
errorCode = 'api_deprecated';
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
message = Constants.userMessages.API_DEPRECATED;
|
|
75
|
-
logger.info(message);
|
|
76
|
-
}
|
|
77
|
-
logger.info(utils.formatRequest(err, resp, body));
|
|
78
|
-
} else if (resp.statusCode != 200) {
|
|
71
|
+
message = build ? build.message : Constants.userMessages.API_DEPRECATED;
|
|
72
|
+
logger.info(utils.formatRequest(response.statusText, response, response.data));
|
|
73
|
+
} else if (response.status != 200) {
|
|
74
|
+
message = Constants.userMessages.BUILD_INFO_FAILED;
|
|
79
75
|
messageType = Constants.messageTypes.ERROR;
|
|
80
76
|
errorCode = 'api_failed_build_info';
|
|
81
|
-
|
|
82
77
|
if (build) {
|
|
83
78
|
message = `${
|
|
84
79
|
Constants.userMessages.BUILD_INFO_FAILED
|
|
85
80
|
} with error: \n${JSON.stringify(build, null, 2)}`;
|
|
86
|
-
logger.error(message);
|
|
87
81
|
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
88
82
|
} else {
|
|
89
83
|
message = Constants.userMessages.BUILD_INFO_FAILED;
|
|
90
|
-
logger.error(message);
|
|
91
84
|
}
|
|
92
|
-
logger.error(
|
|
85
|
+
logger.error(message);
|
|
86
|
+
logger.error(utils.formatRequest(response.statusText, response, response.data));
|
|
93
87
|
} else {
|
|
94
88
|
messageType = Constants.messageTypes.SUCCESS;
|
|
95
89
|
message = `Build info for build id: \n ${JSON.stringify(
|
|
@@ -97,11 +91,18 @@ module.exports = function info(args, rawArgs) {
|
|
|
97
91
|
null,
|
|
98
92
|
2
|
|
99
93
|
)}`;
|
|
100
|
-
logger.info(message);
|
|
101
94
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
logger.info(message);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
message = `${
|
|
98
|
+
Constants.userMessages.BUILD_INFO_FAILED
|
|
99
|
+
} with error: \n${error.response.data.message}`;
|
|
100
|
+
messageType = Constants.messageTypes.ERROR;
|
|
101
|
+
errorCode = 'api_failed_build_info';
|
|
102
|
+
logger.info(message);
|
|
103
|
+
logger.error(utils.formatRequest(error.response.statusText, error.response, error.response.data));
|
|
104
|
+
}
|
|
105
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
105
106
|
}).catch((err) => {
|
|
106
107
|
logger.warn(err);
|
|
107
108
|
});
|
package/bin/commands/runs.js
CHANGED
|
@@ -30,7 +30,6 @@ const {
|
|
|
30
30
|
printBuildLink
|
|
31
31
|
} = require('../testObservability/helper/helper');
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
const {
|
|
35
34
|
createAccessibilityTestRun,
|
|
36
35
|
setAccessibilityEventListeners,
|
|
@@ -39,6 +38,7 @@ const {
|
|
|
39
38
|
} = require('../accessibility-automation/helper');
|
|
40
39
|
const { isTurboScaleSession, getTurboScaleGridDetails, patchCypressConfigFileContent, atsFileCleanup } = require('../helpers/atsHelper');
|
|
41
40
|
|
|
41
|
+
|
|
42
42
|
module.exports = function run(args, rawArgs) {
|
|
43
43
|
|
|
44
44
|
markBlockStart('preBuild');
|
|
@@ -64,15 +64,14 @@ module.exports = function run(args, rawArgs) {
|
|
|
64
64
|
|
|
65
65
|
// set cypress config filename
|
|
66
66
|
utils.setCypressConfigFilename(bsConfig, args);
|
|
67
|
-
|
|
68
|
-
/*
|
|
69
|
-
Set testObservability & browserstackAutomation flags
|
|
70
|
-
*/
|
|
67
|
+
|
|
68
|
+
/* Set testObservability & browserstackAutomation flags */
|
|
71
69
|
const [isTestObservabilitySession, isBrowserstackInfra] = setTestObservabilityFlags(bsConfig);
|
|
72
70
|
const checkAccessibility = checkAccessibilityPlatform(bsConfig);
|
|
73
71
|
const isAccessibilitySession = bsConfig.run_settings.accessibility || checkAccessibility;
|
|
74
72
|
const turboScaleSession = isTurboScaleSession(bsConfig);
|
|
75
73
|
Constants.turboScaleObj.enabled = turboScaleSession;
|
|
74
|
+
|
|
76
75
|
|
|
77
76
|
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
|
|
78
77
|
|
|
@@ -102,6 +101,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
102
101
|
// set spec timeout
|
|
103
102
|
utils.setSpecTimeout(bsConfig, args);
|
|
104
103
|
}
|
|
104
|
+
|
|
105
105
|
|
|
106
106
|
// accept the specs list from command line if provided
|
|
107
107
|
utils.setUserSpecs(bsConfig, args);
|
|
@@ -112,9 +112,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
112
112
|
// set build tag caps
|
|
113
113
|
utils.setBuildTags(bsConfig, args);
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
Send build start to Observability
|
|
117
|
-
*/
|
|
115
|
+
// Send build start to Observability
|
|
118
116
|
if(isTestObservabilitySession) {
|
|
119
117
|
await launchTestSession(bsConfig, bsConfigPath);
|
|
120
118
|
utils.setO11yProcessHooks(null, bsConfig, args, null, buildReportData);
|
|
@@ -379,7 +377,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
379
377
|
});
|
|
380
378
|
} else if(!turboScaleSession){
|
|
381
379
|
let stacktraceUrl = getStackTraceUrl();
|
|
382
|
-
downloadBuildStacktrace(stacktraceUrl).then((message) => {
|
|
380
|
+
downloadBuildStacktrace(stacktraceUrl, bsConfig).then((message) => {
|
|
383
381
|
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
384
382
|
}).catch((err) => {
|
|
385
383
|
let message = `Downloading build stacktrace failed with statuscode: ${err}. Please visit ${data.dashboard_url} for additional details.`;
|
package/bin/commands/stop.js
CHANGED
package/bin/helpers/atsHelper.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const fs = require('fs')
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { consoleHolder } = require('../testObservability/helper/constants');
|
|
4
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
|
3
5
|
|
|
4
|
-
const
|
|
6
|
+
const axios = require('axios'),
|
|
5
7
|
logger = require('./logger').winstonLogger,
|
|
6
8
|
utils = require('./utils'),
|
|
7
9
|
config = require('./config');
|
|
@@ -42,44 +44,52 @@ exports.getTurboScaleGridName = (bsConfig) => {
|
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
exports.getTurboScaleGridDetails = async (bsConfig, args, rawArgs) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
try {
|
|
48
|
+
const gridName = this.getTurboScaleGridName(bsConfig);
|
|
49
|
+
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
let options = {
|
|
52
|
+
url: `${config.turboScaleAPIUrl}/grids/${gridName}`,
|
|
53
|
+
auth: {
|
|
54
|
+
username: bsConfig.auth.username,
|
|
55
|
+
password: bsConfig.auth.access_key,
|
|
56
|
+
},
|
|
57
|
+
headers: {
|
|
58
|
+
'User-Agent': utils.getUserAgent(),
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (process.env.HTTP_PROXY) {
|
|
63
|
+
options.proxy = false;
|
|
64
|
+
options.httpsAgent = new HttpsProxyAgent(process.env.HTTP_PROXY);
|
|
65
|
+
} else if (process.env.HTTPS_PROXY) {
|
|
66
|
+
options.proxy = false;
|
|
67
|
+
options.httpsAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let responseData = {};
|
|
71
|
+
|
|
72
|
+
axios(options).then(response => {
|
|
73
|
+
try {
|
|
74
|
+
responseData = response.data;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
responseData = {};
|
|
77
|
+
}
|
|
78
|
+
if(response.status != 200) {
|
|
79
|
+
logger.warn(`Warn: Get Automate TurboScale Details Request failed with status code ${response.status}`);
|
|
80
|
+
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'get_ats_details_failed', null, rawArgs);
|
|
81
|
+
resolve({});
|
|
82
|
+
}
|
|
83
|
+
resolve(responseData);
|
|
84
|
+
}).catch(error => {
|
|
85
|
+
logger.warn(utils.formatRequest(error, null, null));
|
|
86
|
+
utils.sendUsageReport(bsConfig, args, error, Constants.messageTypes.ERROR, 'get_ats_details_failed', null, rawArgs);
|
|
74
87
|
resolve({});
|
|
75
|
-
|
|
76
|
-
resolve(responseData);
|
|
77
|
-
}
|
|
88
|
+
});
|
|
78
89
|
});
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
logger.error(`Failed to find TurboScale Grid: ${err}: ${err.stack}`);
|
|
92
|
+
}
|
|
83
93
|
};
|
|
84
94
|
|
|
85
95
|
exports.patchCypressConfigFileContent = (bsConfig) => {
|
|
@@ -87,7 +97,6 @@ exports.patchCypressConfigFileContent = (bsConfig) => {
|
|
|
87
97
|
let cypressConfigFileData = fs.readFileSync(path.resolve(bsConfig.run_settings.cypress_config_file)).toString();
|
|
88
98
|
const patchedConfigFileData = cypressConfigFileData + '\n\n' + `
|
|
89
99
|
let originalFunction = module.exports.e2e.setupNodeEvents;
|
|
90
|
-
|
|
91
100
|
module.exports.e2e.setupNodeEvents = (on, config) => {
|
|
92
101
|
const bstackOn = require("./cypressPatch.js")(on);
|
|
93
102
|
if (originalFunction !== null && originalFunction !== undefined) {
|
package/bin/helpers/build.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const
|
|
2
|
+
const axios = require('axios').default;
|
|
3
3
|
|
|
4
4
|
const config = require('./config'),
|
|
5
5
|
capabilityHelper = require("../helpers/capabilityHelper"),
|
|
@@ -7,9 +7,11 @@ const config = require('./config'),
|
|
|
7
7
|
utils = require('../helpers/utils'),
|
|
8
8
|
logger = require('../helpers/logger').winstonLogger;
|
|
9
9
|
|
|
10
|
+
const { setAxiosProxy } = require('./helper');
|
|
11
|
+
|
|
10
12
|
const createBuild = (bsConfig, zip) => {
|
|
11
13
|
return new Promise(function (resolve, reject) {
|
|
12
|
-
capabilityHelper.caps(bsConfig, zip).then(function(data){
|
|
14
|
+
capabilityHelper.caps(bsConfig, zip).then(async function(data){
|
|
13
15
|
let options = {
|
|
14
16
|
url: config.buildUrl,
|
|
15
17
|
auth: {
|
|
@@ -22,43 +24,49 @@ const createBuild = (bsConfig, zip) => {
|
|
|
22
24
|
},
|
|
23
25
|
body: data
|
|
24
26
|
}
|
|
25
|
-
|
|
26
27
|
if (Constants.turboScaleObj.enabled) {
|
|
27
28
|
options.url = Constants.turboScaleObj.buildUrl;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} catch (error) {
|
|
39
|
-
build = null;
|
|
40
|
-
}
|
|
31
|
+
const axiosConfig = {
|
|
32
|
+
auth: {
|
|
33
|
+
username: options.auth.user,
|
|
34
|
+
password: options.auth.password
|
|
35
|
+
},
|
|
36
|
+
headers: options.headers
|
|
37
|
+
}
|
|
38
|
+
setAxiosProxy(axiosConfig);
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
try {
|
|
41
|
+
const response = await axios.post(options.url, data, axiosConfig);
|
|
42
|
+
let build = null;
|
|
43
|
+
try {
|
|
44
|
+
build = response.data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
build = null;
|
|
47
|
+
}
|
|
48
|
+
if (response.status == 299) {
|
|
49
|
+
if (build) {
|
|
50
|
+
resolve(build.message);
|
|
51
|
+
} else {
|
|
52
|
+
logger.error(utils.formatRequest(response.statusText, response, response.data));
|
|
53
|
+
reject(Constants.userMessages.API_DEPRECATED);
|
|
54
|
+
}
|
|
55
|
+
} else if (response.status != 201) {
|
|
56
|
+
logger.error(utils.formatRequest(response.statusText, response, response.data));
|
|
57
|
+
if (build) {
|
|
58
|
+
reject(`${Constants.userMessages.BUILD_FAILED} Error: ${build.message}`);
|
|
56
59
|
} else {
|
|
57
|
-
|
|
60
|
+
reject(Constants.userMessages.BUILD_FAILED);
|
|
58
61
|
}
|
|
59
|
-
resolve(build);
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
resolve(build);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if(error.response) {
|
|
66
|
+
logger.error(utils.formatRequest(error.response.statusText, error.response, error.response.data));
|
|
67
|
+
reject(`${Constants.userMessages.BUILD_FAILED} Error: ${error.response.data.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
62
70
|
}).catch(function(err){
|
|
63
71
|
reject(err);
|
|
64
72
|
});
|