browserstack-cypress-cli 1.19.3 → 1.20.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/commands/runs.js +22 -3
- package/bin/helpers/archiver.js +9 -0
- package/bin/helpers/checkUploaded.js +1 -0
- package/bin/helpers/config.js +2 -0
- package/bin/helpers/constants.js +2 -0
- package/bin/helpers/package-diff.js +93 -0
- package/bin/helpers/sync/specsSummary.js +2 -1
- package/bin/helpers/sync/syncSpecsLogs.js +19 -6
- package/bin/helpers/utils.js +48 -0
- package/bin/helpers/zipUpload.js +43 -5
- package/package.json +2 -2
package/bin/commands/runs.js
CHANGED
|
@@ -19,11 +19,13 @@ const archiver = require("../helpers/archiver"),
|
|
|
19
19
|
downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts,
|
|
20
20
|
downloadBuildStacktrace = require('../helpers/downloadBuildStacktrace').downloadBuildStacktrace,
|
|
21
21
|
updateNotifier = require('update-notifier'),
|
|
22
|
-
pkg = require('../../package.json')
|
|
22
|
+
pkg = require('../../package.json'),
|
|
23
|
+
packageDiff = require('../helpers/package-diff');
|
|
23
24
|
const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
|
|
24
25
|
|
|
25
26
|
module.exports = function run(args, rawArgs) {
|
|
26
27
|
|
|
28
|
+
markBlockStart('preBuild');
|
|
27
29
|
// set debug mode (--cli-debug)
|
|
28
30
|
utils.setDebugMode(args);
|
|
29
31
|
|
|
@@ -158,13 +160,21 @@ module.exports = function run(args, rawArgs) {
|
|
|
158
160
|
// Archive the spec files
|
|
159
161
|
logger.debug("Started archiving test suite");
|
|
160
162
|
markBlockStart('zip.archive');
|
|
161
|
-
return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
|
|
163
|
+
return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(async function (data) {
|
|
162
164
|
logger.debug("Completed archiving test suite");
|
|
163
165
|
markBlockEnd('zip.archive');
|
|
164
166
|
|
|
165
167
|
let test_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.fileName));
|
|
166
168
|
let npm_zip_size = utils.fetchZipSize(path.join(process.cwd(), config.packageFileName));
|
|
167
|
-
|
|
169
|
+
let node_modules_size = await utils.fetchFolderSize(path.join(process.cwd(), "node_modules"))
|
|
170
|
+
|
|
171
|
+
//Package diff
|
|
172
|
+
let isPackageDiff = false;
|
|
173
|
+
if(!md5data.zipUrlPresent){
|
|
174
|
+
isPackageDiff = packageDiff.run(`package.json`, `${config.packageDirName}/package.json`);
|
|
175
|
+
logger.debug(`Package difference was ${isPackageDiff ? `found` : `not found`}`);
|
|
176
|
+
}
|
|
177
|
+
|
|
168
178
|
// Uploaded zip file
|
|
169
179
|
logger.debug("Started uploading the test suite zip");
|
|
170
180
|
logger.debug("Started uploading the node_module zip");
|
|
@@ -185,6 +195,8 @@ module.exports = function run(args, rawArgs) {
|
|
|
185
195
|
logger.debug("Started build creation");
|
|
186
196
|
markBlockStart('createBuild');
|
|
187
197
|
return build.createBuild(bsConfig, zip).then(function (data) {
|
|
198
|
+
markBlockEnd('preBuild');
|
|
199
|
+
markBlockStart('buildProcessing');
|
|
188
200
|
logger.debug("Completed build creation");
|
|
189
201
|
markBlockEnd('createBuild');
|
|
190
202
|
markBlockEnd('total');
|
|
@@ -216,6 +228,8 @@ module.exports = function run(args, rawArgs) {
|
|
|
216
228
|
if (args.sync) {
|
|
217
229
|
logger.debug("Started polling build status from BrowserStack");
|
|
218
230
|
syncRunner.pollBuildStatus(bsConfig, data, rawArgs, buildReportData).then(async (exitCode) => {
|
|
231
|
+
markBlockEnd('buildProcessing');
|
|
232
|
+
markBlockStart('postBuild');
|
|
219
233
|
logger.debug("Completed polling of build status");
|
|
220
234
|
|
|
221
235
|
// stop the Local instance
|
|
@@ -234,6 +248,7 @@ module.exports = function run(args, rawArgs) {
|
|
|
234
248
|
// Generate custom report!
|
|
235
249
|
reportGenerator(bsConfig, data.build_id, args, rawArgs, buildReportData, function(){
|
|
236
250
|
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
251
|
+
markBlockEnd('postBuild');
|
|
237
252
|
utils.handleSyncExit(exitCode, data.dashboard_url);
|
|
238
253
|
});
|
|
239
254
|
} else {
|
|
@@ -267,9 +282,13 @@ module.exports = function run(args, rawArgs) {
|
|
|
267
282
|
build_id: data.build_id,
|
|
268
283
|
test_zip_size: test_zip_size,
|
|
269
284
|
npm_zip_size: npm_zip_size,
|
|
285
|
+
node_modules_size: node_modules_size,
|
|
270
286
|
test_suite_zip_upload: md5data.zipUrlPresent ? 0 : 1,
|
|
271
287
|
package_zip_upload: md5data.packageUrlPresent ? 0 : 1
|
|
272
288
|
};
|
|
289
|
+
if(dataToSend.test_suite_zip_upload === 1 ){
|
|
290
|
+
dataToSend['is_package_diff'] = isPackageDiff;
|
|
291
|
+
}
|
|
273
292
|
|
|
274
293
|
if (!md5data.zipUrlPresent && zip.tests_upload_time) {
|
|
275
294
|
dataToSend.test_suite_zip_size = parseFloat((test_zip_size / 1024).toFixed(2));
|
package/bin/helpers/archiver.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const config = require('./config.js');
|
|
2
3
|
const fs = require("fs"),
|
|
3
4
|
path = require("path");
|
|
4
5
|
|
|
@@ -76,6 +77,14 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
76
77
|
archive.append(packageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-package.json`});
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
//Create copy of package.json
|
|
81
|
+
if(fs.existsSync('package.json')){
|
|
82
|
+
let originalPackageJson = JSON.parse(fs.readFileSync('package.json'));
|
|
83
|
+
let originalPackageJsonString = JSON.stringify(originalPackageJson, null, 4);
|
|
84
|
+
archive.append(originalPackageJsonString, {name: `${cypressAppendFilesZipLocation}userPackage.json`});
|
|
85
|
+
logger.debug(`Created copy of package.json in ${config.packageDirName} folder`)
|
|
86
|
+
}
|
|
87
|
+
|
|
79
88
|
// do not add cypress.json if arg provided is false
|
|
80
89
|
if (
|
|
81
90
|
runSettings.cypress_config_file &&
|
|
@@ -86,6 +86,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
86
86
|
zipUrlPresent: false,
|
|
87
87
|
packageUrlPresent: false,
|
|
88
88
|
};
|
|
89
|
+
utils.setCypressNpmDependency(bsConfig);
|
|
89
90
|
if (args["force-upload"]) {
|
|
90
91
|
logger.debug("force-upload set to true. Uploading tests and npm packages.");
|
|
91
92
|
return resolve(obj);
|
package/bin/helpers/config.js
CHANGED
|
@@ -13,7 +13,9 @@ if(config.env !== "production") {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
config.cypress_v1 = `${config.rails_host}/automate/cypress/v1`;
|
|
16
|
+
config.cypress_v2 = `${config.rails_host}/automate/cypress/v2`;
|
|
16
17
|
config.buildUrl = `${config.cypress_v1}/builds/`;
|
|
18
|
+
config.buildUrlV2 = `${config.cypress_v2}/builds/`;
|
|
17
19
|
config.buildStopUrl = `${config.cypress_v1}/builds/stop/`;
|
|
18
20
|
config.checkMd5sum = `${config.cypress_v1}/md5sumcheck/`;
|
|
19
21
|
config.getInitialDetails = `${config.cypress_v1}/get_initial_details/`;
|
package/bin/helpers/constants.js
CHANGED
|
@@ -110,6 +110,8 @@ const userMessages = {
|
|
|
110
110
|
"Value for the 'spec_timeout' key not in the 1-120 range. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout",
|
|
111
111
|
SPEC_LIMIT_SUCCESS_MESSAGE:
|
|
112
112
|
"Spec timeout specified as <x> minutes. If any of your specs exceed the specified time limit, it would be forcibly killed by BrowserStack",
|
|
113
|
+
NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR:
|
|
114
|
+
"Unable to determine zip upload progress due to undefined/null connection request"
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
const validationMessages = {
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const logger = require("./logger").winstonLogger;
|
|
5
|
+
|
|
6
|
+
exports.run = (basePath, comparePath) => {
|
|
7
|
+
if (!basePath || !comparePath) {
|
|
8
|
+
logger.debug("Skipping package difference check.");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let base;
|
|
12
|
+
let compare;
|
|
13
|
+
let isDiff = false;
|
|
14
|
+
try {
|
|
15
|
+
base = readModules(basePath);
|
|
16
|
+
compare = readModules(comparePath);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
logger.debug('Unable to process package difference');
|
|
19
|
+
return isDiff;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Object.keys(base.deps).forEach((baseKey) => {
|
|
23
|
+
if (baseKey in compare.deps) {
|
|
24
|
+
if (base.deps[baseKey] !== compare.deps[baseKey]) {
|
|
25
|
+
isDiff = true;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
isDiff = true;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return isDiff;
|
|
34
|
+
};
|
|
35
|
+
const readModules = (location) => {
|
|
36
|
+
const table = {};
|
|
37
|
+
|
|
38
|
+
// Resolve package dependencies
|
|
39
|
+
if (location.indexOf("package.json") !== -1) {
|
|
40
|
+
const data = fs.readFileSync(location.replace(":dev", ""), "utf-8");
|
|
41
|
+
let parsed;
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(data);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
parsed = false;
|
|
46
|
+
}
|
|
47
|
+
if (!parsed) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const depsKey =
|
|
52
|
+
location.indexOf(":dev") !== -1 ? "devDependencies" : "dependencies";
|
|
53
|
+
const deps = parsed[depsKey]
|
|
54
|
+
? parsed[depsKey]
|
|
55
|
+
: parsed.dependencies || parsed.devDependencies;
|
|
56
|
+
|
|
57
|
+
Object.keys(deps).forEach((key) => {
|
|
58
|
+
deps[key] = deps[key].replace(/\^|~/g, "");
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
name: `${location} {${depsKey}}`,
|
|
62
|
+
deps,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fs.readdirSync(location)
|
|
67
|
+
.filter((name) => name !== ".bin")
|
|
68
|
+
.map((name) => {
|
|
69
|
+
const pkg = path.join(location, name, "package.json");
|
|
70
|
+
const exists = fs.existsSync(pkg);
|
|
71
|
+
if (!exists) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const data = fs.readFileSync(pkg, "utf-8");
|
|
76
|
+
let parsed;
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(data);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
parsed = false;
|
|
82
|
+
}
|
|
83
|
+
if (!parsed) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
table[name] = parsed.version;
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
name: location,
|
|
91
|
+
deps: table,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -33,7 +33,8 @@ let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}, passed_with_skipped: ${summary.passed_with_skipped}, pending: ${summary.pending}`);
|
|
36
|
-
logger.info(`Done in ${data.duration
|
|
36
|
+
logger.info(`Done in ${data.duration} seconds using ${data.parallels} machines\n`);
|
|
37
|
+
winstonlogger.debug(`CLI calculated duration is ${data.cliDuration/1000}`);
|
|
37
38
|
|
|
38
39
|
if (customErrorsToPrint && customErrorsToPrint.length > 0) {
|
|
39
40
|
for (const error of customErrorsToPrint) {
|
|
@@ -14,6 +14,8 @@ let specSummary = {
|
|
|
14
14
|
"buildError": null,
|
|
15
15
|
"specs": [],
|
|
16
16
|
"duration": null,
|
|
17
|
+
"parallels": null,
|
|
18
|
+
"cliDuration": null,
|
|
17
19
|
"customErrorsToPrint": []
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -24,7 +26,7 @@ if (!isNaN(terminalWidth)) lineSeparator = "\n" + "-".repeat(terminalWidth);
|
|
|
24
26
|
|
|
25
27
|
let getOptions = (auth, build_id) => {
|
|
26
28
|
return {
|
|
27
|
-
url: `${config.
|
|
29
|
+
url: `${config.buildUrlV2}${build_id}`,
|
|
28
30
|
auth: {
|
|
29
31
|
user: auth.username,
|
|
30
32
|
password: auth.access_key
|
|
@@ -120,7 +122,7 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
logger.info(lineSeparator);
|
|
123
|
-
specSummary.
|
|
125
|
+
specSummary.cliDuration = endTime - startTime
|
|
124
126
|
resolve(specSummary);
|
|
125
127
|
}
|
|
126
128
|
);
|
|
@@ -147,7 +149,7 @@ let whileProcess = (whilstCallback) => {
|
|
|
147
149
|
switch (response.statusCode) {
|
|
148
150
|
case 202: // get data here and print it
|
|
149
151
|
n = 2
|
|
150
|
-
showSpecsStatus(body);
|
|
152
|
+
showSpecsStatus(body, 202);
|
|
151
153
|
return setTimeout(whilstCallback, timeout * n, null);
|
|
152
154
|
case 204: // No data available, wait for some time and ask again
|
|
153
155
|
n = 1
|
|
@@ -155,7 +157,7 @@ let whileProcess = (whilstCallback) => {
|
|
|
155
157
|
case 200: // Build is completed.
|
|
156
158
|
whileLoop = false;
|
|
157
159
|
endTime = Date.now();
|
|
158
|
-
showSpecsStatus(body);
|
|
160
|
+
showSpecsStatus(body, 200);
|
|
159
161
|
return specSummary.exitCode == Constants.BUILD_FAILED_EXIT_CODE ?
|
|
160
162
|
whilstCallback({ status: 204, message: "No specs ran in the build"} ) : whilstCallback(null, body);
|
|
161
163
|
default:
|
|
@@ -169,9 +171,9 @@ let getStackTraceUrl = () => {
|
|
|
169
171
|
return specSummary.buildError
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
let showSpecsStatus = (data) => {
|
|
174
|
+
let showSpecsStatus = (data, statusCode) => {
|
|
173
175
|
let specData = JSON.parse(data);
|
|
174
|
-
specData.forEach(specDetails => {
|
|
176
|
+
specData["specData"].forEach(specDetails => {
|
|
175
177
|
if (specDetails.type === Constants.CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY) {
|
|
176
178
|
addCustomErrorToPrint(specDetails);
|
|
177
179
|
} else {
|
|
@@ -190,6 +192,17 @@ let showSpecsStatus = (data) => {
|
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
});
|
|
195
|
+
if ( statusCode != 200 ) return;
|
|
196
|
+
// Below block is for printing build details, return if non 200 status code
|
|
197
|
+
if ("buildData" in specData) {
|
|
198
|
+
const buildDetails = specData.buildData;
|
|
199
|
+
const totalDuration = (utils.isUndefined(buildDetails.duration)) ? "-" : buildDetails.duration.total_duration
|
|
200
|
+
const parallels = (utils.isUndefined(buildDetails.parallels)) ? "-" : buildDetails.parallels
|
|
201
|
+
specSummary.duration = totalDuration;
|
|
202
|
+
specSummary.parallels = parallels;
|
|
203
|
+
} else {
|
|
204
|
+
logger.debug(`Build details not sent`)
|
|
205
|
+
}
|
|
193
206
|
}
|
|
194
207
|
|
|
195
208
|
let printInitialLog = () => {
|
package/bin/helpers/utils.js
CHANGED
|
@@ -8,6 +8,9 @@ const { v4: uuidv4 } = require('uuid');
|
|
|
8
8
|
const browserstack = require('browserstack-local');
|
|
9
9
|
const crypto = require('crypto');
|
|
10
10
|
const util = require('util');
|
|
11
|
+
const { promisify } = require('util');
|
|
12
|
+
const readdir = promisify(fs.readdir);
|
|
13
|
+
const stat = promisify(fs.stat);
|
|
11
14
|
|
|
12
15
|
const usageReporting = require("./usageReporting"),
|
|
13
16
|
logger = require("./logger").winstonLogger,
|
|
@@ -328,6 +331,23 @@ exports.setCypressTestSuiteType = (bsConfig) => {
|
|
|
328
331
|
logger.debug(`Setting cypress test suite type as ${bsConfig.run_settings.cypressTestSuiteType}`);
|
|
329
332
|
}
|
|
330
333
|
|
|
334
|
+
exports.setCypressNpmDependency = (bsConfig) => {
|
|
335
|
+
const runSettings = bsConfig.run_settings;
|
|
336
|
+
if (runSettings.npm_dependencies !== undefined &&
|
|
337
|
+
Object.keys(runSettings.npm_dependencies).length !== 0 &&
|
|
338
|
+
typeof runSettings.npm_dependencies === 'object') {
|
|
339
|
+
if (!("cypress" in runSettings.npm_dependencies) && runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
340
|
+
logger.warn("Missing cypress not found in npm_dependencies");
|
|
341
|
+
if("cypress_version" in runSettings){
|
|
342
|
+
runSettings.npm_dependencies.cypress = `^${runSettings.cypress_version.toString().split(".")[0]}`;
|
|
343
|
+
} else if (runSettings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE) {
|
|
344
|
+
runSettings.npm_dependencies.cypress = "latest";
|
|
345
|
+
}
|
|
346
|
+
logger.warn(`Adding cypress version ${runSettings.npm_dependencies.cypress} in npm_dependencies`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
331
351
|
exports.verifyGeolocationOption = () => {
|
|
332
352
|
let glOptionsSet = (this.searchForOption('-gl') || this.searchForOption('--gl'));
|
|
333
353
|
let geoHyphenLocationOptionsSet = (this.searchForOption('-geo-location') || this.searchForOption('--geo-location'));
|
|
@@ -1278,6 +1298,34 @@ exports.fetchZipSize = (fileName) => {
|
|
|
1278
1298
|
}
|
|
1279
1299
|
}
|
|
1280
1300
|
|
|
1301
|
+
const getDirectorySize = async function(dir) {
|
|
1302
|
+
try{
|
|
1303
|
+
const subdirs = (await readdir(dir));
|
|
1304
|
+
const files = await Promise.all(subdirs.map(async (subdir) => {
|
|
1305
|
+
const res = path.resolve(dir, subdir);
|
|
1306
|
+
const s = (await stat(res));
|
|
1307
|
+
return s.isDirectory() ? getDirectorySize(res) : (s.size);
|
|
1308
|
+
}));
|
|
1309
|
+
return files.reduce((a, f) => a+f, 0);
|
|
1310
|
+
}catch(e){
|
|
1311
|
+
console.log(`Error ${e}`)
|
|
1312
|
+
logger.debug('Failed to get file or directory.');
|
|
1313
|
+
return 0;
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
exports.fetchFolderSize = async (dir) => {
|
|
1318
|
+
try {
|
|
1319
|
+
if(fs.existsSync(dir)){
|
|
1320
|
+
return (await getDirectorySize(dir) / 1024 / 1024);
|
|
1321
|
+
}
|
|
1322
|
+
return 0;
|
|
1323
|
+
} catch (error) {
|
|
1324
|
+
logger.debug(`Failed to get directory size.`);
|
|
1325
|
+
return 0;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1281
1329
|
exports.getVideoConfig = (cypressConfig) => {
|
|
1282
1330
|
let conf = {
|
|
1283
1331
|
video: true,
|
package/bin/helpers/zipUpload.js
CHANGED
|
@@ -21,6 +21,10 @@ const purgeUploadBar = (obj) => {
|
|
|
21
21
|
|
|
22
22
|
const uploadSuits = (bsConfig, filePath, opts, obj) => {
|
|
23
23
|
return new Promise(function (resolve, reject) {
|
|
24
|
+
let uploadProgressBarErrorFlags = {
|
|
25
|
+
noConnectionReportSent: false,
|
|
26
|
+
unknownErrorReportSent: false
|
|
27
|
+
};
|
|
24
28
|
obj.startTime = Date.now();
|
|
25
29
|
|
|
26
30
|
if (opts.urlPresent) {
|
|
@@ -96,11 +100,45 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
|
|
|
96
100
|
});
|
|
97
101
|
|
|
98
102
|
obj.zipInterval = setInterval(function () {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
const errorCode = 'update_upload_progress_bar_failed';
|
|
104
|
+
try {
|
|
105
|
+
if (r && r.req && r.req.connection) {
|
|
106
|
+
let dispatched = r.req.connection._bytesDispatched;
|
|
107
|
+
let percent = dispatched * 100.0 / size;
|
|
108
|
+
obj.bar1.update(percent, {
|
|
109
|
+
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
if (!uploadProgressBarErrorFlags.noConnectionReportSent) {
|
|
113
|
+
logger.debug(Constants.userMessages.NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR);
|
|
114
|
+
utils.sendUsageReport(
|
|
115
|
+
bsConfig,
|
|
116
|
+
null,
|
|
117
|
+
Constants.userMessages.NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR,
|
|
118
|
+
Constants.messageTypes.WARNING,
|
|
119
|
+
errorCode,
|
|
120
|
+
null,
|
|
121
|
+
null
|
|
122
|
+
);
|
|
123
|
+
uploadProgressBarErrorFlags.noConnectionReportSent = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (!uploadProgressBarErrorFlags.unknownErrorReportSent) {
|
|
128
|
+
logger.debug('Unable to determine progress.');
|
|
129
|
+
logger.debug(error);
|
|
130
|
+
utils.sendUsageReport(
|
|
131
|
+
bsConfig,
|
|
132
|
+
null,
|
|
133
|
+
error.stack,
|
|
134
|
+
Constants.messageTypes.WARNING,
|
|
135
|
+
errorCode,
|
|
136
|
+
null,
|
|
137
|
+
null
|
|
138
|
+
);
|
|
139
|
+
uploadProgressBarErrorFlags.unknownErrorReportSent = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
104
142
|
}, 150);
|
|
105
143
|
|
|
106
144
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browserstack-cypress-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"chai": "4.3.6",
|
|
43
43
|
"chai-as-promised": "7.1.1",
|
|
44
44
|
"custom-env": "2.0.1",
|
|
45
|
-
"mocha": "
|
|
45
|
+
"mocha": "^10.2.0",
|
|
46
46
|
"nyc": "15.1.0",
|
|
47
47
|
"proxyquire": "2.1.3",
|
|
48
48
|
"rewire": "5.0.0",
|