browserstack-cypress-cli 1.14.0 → 1.16.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/generateDownloads.js +6 -3
- package/bin/commands/generateReport.js +18 -12
- package/bin/commands/info.js +73 -68
- package/bin/commands/runs.js +26 -24
- package/bin/commands/stop.js +5 -2
- package/bin/helpers/buildArtifacts.js +9 -9
- package/bin/helpers/capabilityHelper.js +3 -0
- package/bin/helpers/config.js +1 -0
- package/bin/helpers/constants.js +4 -2
- package/bin/helpers/getInitialDetails.js +41 -0
- package/bin/helpers/packageInstaller.js +19 -3
- package/bin/helpers/reporterHTML.js +58 -265
- package/bin/helpers/sync/failedSpecsDetails.js +12 -4
- package/bin/helpers/sync/specsSummary.js +10 -2
- package/bin/helpers/sync/syncSpecsLogs.js +10 -7
- package/bin/helpers/syncRunner.js +2 -2
- package/bin/helpers/usageReporting.js +1 -0
- package/bin/helpers/utils.js +64 -12
- package/bin/runner.js +6 -0
- package/log/usage.log +2 -0
- package/package.json +3 -3
|
@@ -1,94 +1,13 @@
|
|
|
1
1
|
const fs = require('fs'),
|
|
2
2
|
path = require('path'),
|
|
3
3
|
request = require('request'),
|
|
4
|
+
unzipper = require('unzipper'),
|
|
4
5
|
logger = require('./logger').winstonLogger,
|
|
5
6
|
utils = require("./utils"),
|
|
6
7
|
Constants = require('./constants'),
|
|
7
8
|
config = require("./config");
|
|
8
9
|
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
function loadInlineCss() {
|
|
12
|
-
return loadFile(path.join(templatesDir, 'assets', 'browserstack-cypress-report.css'));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function loadFile(fileName) {
|
|
16
|
-
return fs.readFileSync(fileName, 'utf8');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function createBodyBuildHeader(report_data){
|
|
20
|
-
let projectNameSpan = `<span class='project-name'> ${report_data.project_name} </span>`;
|
|
21
|
-
let buildNameSpan = `<span class='build-name'> ${report_data.build_name} </span>`;
|
|
22
|
-
let buildMeta = `<div class='build-meta'> ${buildNameSpan} ${projectNameSpan} </div>`;
|
|
23
|
-
let buildLink = `<div class='build-link'> <a href='${report_data.build_url}' rel='noreferrer noopener' target='_blank'> View on BrowserStack </a> </div>`;
|
|
24
|
-
let buildHeader = `<div class='build-header'> ${buildMeta} ${buildLink} </div>`;
|
|
25
|
-
return buildHeader;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function createBodyBuildTable(report_data) {
|
|
29
|
-
let specs = Object.keys(report_data.rows),
|
|
30
|
-
specRow = '',
|
|
31
|
-
specSessions = '',
|
|
32
|
-
sessionBlocks = '',
|
|
33
|
-
specData,
|
|
34
|
-
specNameSpan,
|
|
35
|
-
specPathSpan,
|
|
36
|
-
specStats,
|
|
37
|
-
specStatsSpan,
|
|
38
|
-
specMeta,
|
|
39
|
-
sessionStatus,
|
|
40
|
-
sessionClass,
|
|
41
|
-
sessionStatusIcon,
|
|
42
|
-
sessionLink;
|
|
43
|
-
|
|
44
|
-
specs.forEach((specName) => {
|
|
45
|
-
specData = report_data.rows[specName];
|
|
46
|
-
|
|
47
|
-
specNameSpan = `<span class='spec-name'> ${specName} </span>`;
|
|
48
|
-
specPathSpan = `<span class='spec-path'> ${specData.path} </span>`;
|
|
49
|
-
|
|
50
|
-
specStats = buildSpecStats(specData.meta);
|
|
51
|
-
specStatsSpan = `<span class='spec-stats ${specStats.cssClass}'> ${specStats.label} </span>`;
|
|
52
|
-
|
|
53
|
-
specMeta = `<div class='spec-meta'> ${specNameSpan} ${specPathSpan} ${specStatsSpan} </div>`;
|
|
54
|
-
sessionBlocks = '';
|
|
55
|
-
specData.sessions.forEach((specSession) => {
|
|
56
|
-
|
|
57
|
-
sessionStatus = specSession.status;
|
|
58
|
-
sessionClass = sessionStatus === 'passed' ? 'session-passed' : 'session-failed';
|
|
59
|
-
sessionStatusIcon = sessionStatus === 'passed' ? "✔ " : "✗ ";
|
|
60
|
-
|
|
61
|
-
sessionLink = `<a href="${specSession.link}" rel="noreferrer noopener" target="_blank"> ${sessionStatusIcon} ${specSession.name} </a>`;
|
|
62
|
-
|
|
63
|
-
sessionDetail = `<div class="session-detail ${sessionClass}"> ${sessionLink} </div>`;
|
|
64
|
-
sessionBlocks = `${sessionBlocks} ${sessionDetail}`;
|
|
65
|
-
});
|
|
66
|
-
specSessions = `<div class='spec-sessions'> ${sessionBlocks} </div>`;
|
|
67
|
-
specRow = `${specRow} <div class='spec-row'> ${specMeta} ${specSessions} </div>`;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return `<div class='build-table'> ${specRow} </div>`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function buildSpecStats(specMeta) {
|
|
75
|
-
let failedSpecs = specMeta.failed,
|
|
76
|
-
passedSpecs = specMeta.passed,
|
|
77
|
-
totalSpecs = specMeta.total,
|
|
78
|
-
specStats = {};
|
|
79
|
-
|
|
80
|
-
if (failedSpecs) {
|
|
81
|
-
specStats.label = `${failedSpecs}/${totalSpecs} FAILED`;
|
|
82
|
-
specStats.cssClass = 'spec-stats-failed';
|
|
83
|
-
} else {
|
|
84
|
-
specStats.label = `${passedSpecs}/${totalSpecs} PASSED`;
|
|
85
|
-
specStats.cssClass = 'spec-stats-passed';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return specStats;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
10
|
+
let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => {
|
|
92
11
|
let options = {
|
|
93
12
|
url: `${config.buildUrl}${buildId}/custom_report`,
|
|
94
13
|
auth: {
|
|
@@ -100,6 +19,8 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
100
19
|
},
|
|
101
20
|
};
|
|
102
21
|
|
|
22
|
+
logger.debug('Started fetching the build json and html reports.');
|
|
23
|
+
|
|
103
24
|
return request.get(options, async function (err, resp, body) {
|
|
104
25
|
let message = null;
|
|
105
26
|
let messageType = null;
|
|
@@ -114,9 +35,10 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
114
35
|
logger.error('Generating the build report failed.');
|
|
115
36
|
logger.error(utils.formatRequest(err, resp, body));
|
|
116
37
|
|
|
117
|
-
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode,
|
|
38
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
118
39
|
return;
|
|
119
40
|
} else {
|
|
41
|
+
logger.debug('Received reports data from upstream.');
|
|
120
42
|
try {
|
|
121
43
|
build = JSON.parse(body);
|
|
122
44
|
} catch (error) {
|
|
@@ -127,7 +49,6 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
127
49
|
if (resp.statusCode == 299) {
|
|
128
50
|
messageType = Constants.messageTypes.INFO;
|
|
129
51
|
errorCode = 'api_deprecated';
|
|
130
|
-
|
|
131
52
|
if (build) {
|
|
132
53
|
message = build.message;
|
|
133
54
|
logger.info(message);
|
|
@@ -163,209 +84,81 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
163
84
|
} else {
|
|
164
85
|
messageType = Constants.messageTypes.SUCCESS;
|
|
165
86
|
message = `Report for build: ${buildId} was successfully created.`;
|
|
166
|
-
await
|
|
87
|
+
await generateCypressBuildReport(build);
|
|
167
88
|
logger.info(message);
|
|
168
89
|
}
|
|
169
|
-
|
|
90
|
+
logger.debug('Finished fetching the build json and html reports.');
|
|
91
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
170
92
|
if (cb){
|
|
171
93
|
cb();
|
|
172
94
|
}
|
|
173
95
|
});
|
|
174
96
|
}
|
|
175
97
|
|
|
176
|
-
async function
|
|
177
|
-
let resultsDir = 'results';
|
|
178
|
-
let metaCharSet = `<meta charset="utf-8">`;
|
|
179
|
-
let metaViewPort = `<meta name="viewport" content="width=device-width, initial-scale=1"> `;
|
|
180
|
-
let pageTitle = `<title> BrowserStack Cypress Report </title>`;
|
|
181
|
-
let inlineCss = `<style type="text/css"> ${loadInlineCss()} </style>`;
|
|
182
|
-
let head = `<head> ${metaCharSet} ${metaViewPort} ${pageTitle} ${inlineCss} </head>`;
|
|
183
|
-
let htmlOpenTag = `<!DOCTYPE HTML><html>`;
|
|
184
|
-
let htmlClosetag = `</html>`;
|
|
185
|
-
let bodyBuildHeader = createBodyBuildHeader(report_data);
|
|
186
|
-
let bodyBuildTable = createBodyBuildTable(report_data);
|
|
187
|
-
let bodyReporterContainer = `<div class='report-container'> ${bodyBuildHeader} ${bodyBuildTable} </div>`;
|
|
188
|
-
let body = `<body> ${bodyReporterContainer} </body>`;
|
|
189
|
-
let html = `${htmlOpenTag} ${head} ${body} ${htmlClosetag}`;
|
|
190
|
-
|
|
98
|
+
async function generateCypressBuildReport(report_data) {
|
|
99
|
+
let resultsDir = path.join('./', 'results');
|
|
191
100
|
|
|
192
101
|
if (!fs.existsSync(resultsDir)){
|
|
102
|
+
logger.debug("Results directory doesn't exists.");
|
|
103
|
+
logger.debug("Creating results directory.");
|
|
193
104
|
fs.mkdirSync(resultsDir);
|
|
194
105
|
}
|
|
195
|
-
|
|
196
|
-
// Writing the JSON used in creating the HTML file.
|
|
197
|
-
let reportData = await cypressReportData(report_data);
|
|
198
|
-
fs.writeFileSync(
|
|
199
|
-
`${resultsDir}/browserstack-cypress-report.json`,
|
|
200
|
-
JSON.stringify(reportData),
|
|
201
|
-
() => {
|
|
202
|
-
if (err) {
|
|
203
|
-
return logger.error(err);
|
|
204
|
-
}
|
|
205
|
-
logger.info("The JSON file is saved");
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
// Writing the HTML file generated from the JSON data.
|
|
210
|
-
fs.writeFileSync(`${resultsDir}/browserstack-cypress-report.html`, html, () => {
|
|
211
|
-
if(err) {
|
|
212
|
-
return logger.error(err);
|
|
213
|
-
}
|
|
214
|
-
logger.info("The HTML file was saved!");
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
async function cypressReportData(report_data) {
|
|
219
|
-
specFiles = Object.keys(report_data.rows);
|
|
220
|
-
combinationPromises = [];
|
|
221
|
-
for (let spec of specFiles) {
|
|
222
|
-
let specSessions = report_data.rows[spec]["sessions"];
|
|
223
|
-
if (specSessions.length > 0) {
|
|
224
|
-
for (let combination of specSessions) {
|
|
225
|
-
if(utils.isUndefined(report_data.cypress_version) || report_data.cypress_version < "6"){
|
|
226
|
-
combinationPromises.push(generateCypressCombinationSpecReportDataWithoutConfigJson(combination));
|
|
227
|
-
}else{
|
|
228
|
-
combinationPromises.push(generateCypressCombinationSpecReportDataWithConfigJson(combination));
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
await Promise.all(combinationPromises);
|
|
234
|
-
return report_data;
|
|
106
|
+
await getReportResponse(resultsDir, 'report.zip', report_data.cypress_custom_report_url);
|
|
235
107
|
}
|
|
236
108
|
|
|
237
|
-
function
|
|
109
|
+
function getReportResponse(filePath, fileName, reportJsonUrl) {
|
|
110
|
+
let tmpFilePath = path.join(filePath, fileName);
|
|
111
|
+
const writer = fs.createWriteStream(tmpFilePath);
|
|
112
|
+
logger.debug(`Fetching build reports zip.`)
|
|
238
113
|
return new Promise(async (resolve, reject) => {
|
|
239
|
-
|
|
240
|
-
configJsonError = false
|
|
241
|
-
request.get(combination.tests.config_json , function(err, resp, body) {
|
|
242
|
-
if(err) {
|
|
243
|
-
configJsonError = true;
|
|
244
|
-
reject([configJsonResponse, configJsonError]);
|
|
245
|
-
} else {
|
|
246
|
-
if(resp.statusCode != 200) {
|
|
247
|
-
configJsonError = true;
|
|
248
|
-
reject([configJsonResponse, configJsonError]);
|
|
249
|
-
} else {
|
|
250
|
-
try {
|
|
251
|
-
configJsonResponse = JSON.parse(body);
|
|
252
|
-
} catch (err) {
|
|
253
|
-
configJsonError = true
|
|
254
|
-
reject([configJsonResponse, configJsonError]);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
resolve([configJsonResponse, configJsonError]);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
}
|
|
114
|
+
request.get(reportJsonUrl).on('response', function(response) {
|
|
262
115
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
resultsJsonError = false;
|
|
267
|
-
request.get(combination.tests.result_json , function(err, resp, body) {
|
|
268
|
-
if(err) {
|
|
269
|
-
resultsJsonError = true;
|
|
270
|
-
reject([resultsJsonResponse, resultsJsonError]);
|
|
116
|
+
if(response.statusCode != 200) {
|
|
117
|
+
let message = `Received non 200 response while fetching reports, code: ${response.statusCode}`;
|
|
118
|
+
reject(message);
|
|
271
119
|
} else {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
resolve([resultsJsonResponse, resultsJsonError]);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function generateCypressCombinationSpecReportDataWithConfigJson(combination){
|
|
290
|
-
return new Promise(async (resolve, reject) => {
|
|
291
|
-
try {
|
|
292
|
-
let configJsonError, resultsJsonError;
|
|
293
|
-
let configJson, resultsJson;
|
|
294
|
-
|
|
295
|
-
await Promise.all([getConfigJsonResponse(combination), getResultsJsonResponse(combination)]).then(function (successResult) {
|
|
296
|
-
[[configJson, configJsonError], [resultsJson, resultsJsonError]] = successResult;
|
|
297
|
-
}).catch(function (failureResult) {
|
|
298
|
-
[[configJson, configJsonError], [resultsJson, resultsJsonError]] = failureResult;
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
if(resultsJsonError || configJsonError){
|
|
302
|
-
resolve();
|
|
303
|
-
}
|
|
304
|
-
let tests = {};
|
|
305
|
-
if(utils.isUndefined(configJson.tests) || utils.isUndefined(resultsJson.tests)){
|
|
306
|
-
resolve();
|
|
307
|
-
}
|
|
308
|
-
configJson.tests.forEach((test) => {
|
|
309
|
-
tests[test["clientId"]] = test;
|
|
120
|
+
//ensure that the user can call `then()` only when the file has
|
|
121
|
+
//been downloaded entirely.
|
|
122
|
+
response.pipe(writer);
|
|
123
|
+
let error = null;
|
|
124
|
+
writer.on('error', err => {
|
|
125
|
+
error = err;
|
|
126
|
+
writer.close();
|
|
127
|
+
reject(err);
|
|
128
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
310
129
|
});
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
130
|
+
writer.on('close', async () => {
|
|
131
|
+
if (!error) {
|
|
132
|
+
logger.debug("Unzipping downloaded html and json reports.");
|
|
133
|
+
unzipFile(filePath, fileName).then((msg) => {
|
|
134
|
+
logger.debug(msg);
|
|
135
|
+
fs.unlinkSync(tmpFilePath);
|
|
136
|
+
logger.debug("Successfully prepared json and html reports.");
|
|
137
|
+
resolve(true);
|
|
138
|
+
}).catch((err) =>{
|
|
139
|
+
logger.debug(`Unzipping html and json report failed. Error: ${err}`)
|
|
140
|
+
reject(true);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//no need to call the reject here, as it will have been called in the
|
|
144
|
+
//'error' stream;
|
|
326
145
|
});
|
|
327
|
-
combination.tests = sessionTests;
|
|
328
|
-
resolve(combination.tests);
|
|
329
|
-
} catch (error) {
|
|
330
|
-
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
331
|
-
reject(error);
|
|
332
146
|
}
|
|
333
|
-
|
|
147
|
+
});
|
|
148
|
+
});
|
|
334
149
|
}
|
|
335
150
|
|
|
336
|
-
|
|
337
|
-
return new Promise(async (resolve, reject) => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}).catch( function (failureResult) {
|
|
343
|
-
[resultsJson, resultsJsonError] = failureResult
|
|
344
|
-
})
|
|
345
|
-
if(resultsJsonError || utils.isUndefined(resultsJsonResponse)){
|
|
346
|
-
resolve();
|
|
347
|
-
}
|
|
348
|
-
let sessionTests = [];
|
|
349
|
-
if(utils.isUndefined(resultsJson.tests)){
|
|
350
|
-
resolve();
|
|
351
|
-
}
|
|
352
|
-
resultsJson.tests.forEach((test) => {
|
|
353
|
-
durationKey = utils.isUndefined(test["attempts"]) ? test : test["attempts"].pop()
|
|
354
|
-
sessionTests.push({
|
|
355
|
-
name: test["title"].pop(),
|
|
356
|
-
status: test["state"],
|
|
357
|
-
duration: parseFloat(
|
|
358
|
-
durationKey["wallClockDuration"] / 1000
|
|
359
|
-
).toFixed(2)
|
|
360
|
-
})
|
|
361
|
-
});
|
|
362
|
-
combination.tests = sessionTests;
|
|
363
|
-
resolve(combination.tests);
|
|
364
|
-
} catch (error) {
|
|
151
|
+
const unzipFile = async (filePath, fileName) => {
|
|
152
|
+
return new Promise( async (resolve, reject) => {
|
|
153
|
+
await unzipper.Open.file(path.join(filePath, fileName))
|
|
154
|
+
.then(d => d.extract({path: filePath, concurrency: 5}))
|
|
155
|
+
.catch((err) => {
|
|
156
|
+
reject(err);
|
|
365
157
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
158
|
+
});
|
|
159
|
+
let message = "Unzipped the json and html successfully."
|
|
160
|
+
resolve(message);
|
|
161
|
+
});
|
|
369
162
|
}
|
|
370
163
|
|
|
371
164
|
exports.reportGenerator = reportGenerator;
|
|
@@ -38,10 +38,7 @@ let failedSpecsDetails = (data) => {
|
|
|
38
38
|
if (spec.status && spec.status.toLowerCase() === 'failed' && !failedSpecs)
|
|
39
39
|
failedSpecs = true;
|
|
40
40
|
|
|
41
|
-
let specStatus =
|
|
42
|
-
spec.status && spec.status.toLowerCase() === 'failed'
|
|
43
|
-
? chalk.red(spec.status)
|
|
44
|
-
: chalk.yellow(spec.status);
|
|
41
|
+
let specStatus = getSpecStatus(spec.status)
|
|
45
42
|
specData.push([
|
|
46
43
|
spec.specName,
|
|
47
44
|
specStatus,
|
|
@@ -79,4 +76,15 @@ let failedSpecsDetails = (data) => {
|
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
|
|
79
|
+
let getSpecStatus = (specStatus) => {
|
|
80
|
+
switch(specStatus.toLowerCase()) {
|
|
81
|
+
case 'failed': return chalk.red(specStatus);
|
|
82
|
+
case 'pending':
|
|
83
|
+
case 'skipped':
|
|
84
|
+
case 'passed_with_skipped': return chalk.blueBright(specStatus);
|
|
85
|
+
default: return chalk.yellow(specStatus);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
exports.failedSpecsDetails = failedSpecsDetails;
|
|
90
|
+
exports.getSpecStatus = getSpecStatus;
|
|
@@ -23,14 +23,16 @@ let printSpecsRunSummary = (data, machines, customErrorsToPrint) => {
|
|
|
23
23
|
total: 0,
|
|
24
24
|
failed: 0,
|
|
25
25
|
passed: 0,
|
|
26
|
-
skipped: 0
|
|
26
|
+
skipped: 0,
|
|
27
|
+
passed_with_skipped: 0,
|
|
28
|
+
pending: 0
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
data.specs.forEach((spec) => {
|
|
30
32
|
specSummaryCount(summary, spec.status.toLowerCase());
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
logger.info(`Total tests: ${summary.total}, passed: ${summary.passed}, failed: ${summary.failed}, skipped: ${summary.skipped}`);
|
|
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}`);
|
|
34
36
|
logger.info(`Done in ${data.duration/1000} seconds using ${machines} machines\n`);
|
|
35
37
|
|
|
36
38
|
if (customErrorsToPrint && customErrorsToPrint.length > 0) {
|
|
@@ -57,9 +59,15 @@ let specSummaryCount = (summary, status) => {
|
|
|
57
59
|
case 'failed':
|
|
58
60
|
summary.failed++;
|
|
59
61
|
break;
|
|
62
|
+
case "passed_with_skipped":
|
|
63
|
+
summary.passed_with_skipped++;
|
|
64
|
+
break;
|
|
60
65
|
case 'skipped':
|
|
61
66
|
summary.skipped++;
|
|
62
67
|
break;
|
|
68
|
+
case "pending":
|
|
69
|
+
summary.pending++;
|
|
70
|
+
break;
|
|
63
71
|
case 'passed':
|
|
64
72
|
summary.passed++;
|
|
65
73
|
break;
|
|
@@ -96,7 +96,7 @@ let setNoWrapParams = () => {
|
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
|
|
99
|
+
let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
|
|
100
100
|
setNoWrapParams();
|
|
101
101
|
return new Promise((resolve, reject) => {
|
|
102
102
|
options = getOptions(bsConfig.auth, buildDetails.build_id)
|
|
@@ -116,7 +116,7 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
|
|
|
116
116
|
if(err.status == 204) {
|
|
117
117
|
reject(specSummary.exitCode);
|
|
118
118
|
} else {
|
|
119
|
-
utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', err, rawArgs);
|
|
119
|
+
utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', { ...err , ...buildReportData}, rawArgs);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
logger.info(lineSeparator);
|
|
@@ -201,13 +201,14 @@ let printInitialLog = () => {
|
|
|
201
201
|
|
|
202
202
|
let printSpecData = (data) => {
|
|
203
203
|
let combination = getCombinationName(data["spec"]);
|
|
204
|
-
let status =
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
let status = data["spec"]["status"];
|
|
205
|
+
let statusMark = getStatus(status);
|
|
206
|
+
writeToTable(combination, data["path"], status, statusMark)
|
|
207
|
+
addSpecToSummary(data["path"], status, combination, data["session_id"])
|
|
207
208
|
}
|
|
208
209
|
|
|
209
|
-
let writeToTable = (combination, specName, status) => {
|
|
210
|
-
stream.write([combination , ":", `${specName} ${status}`]);
|
|
210
|
+
let writeToTable = (combination, specName, status, statusMark) => {
|
|
211
|
+
stream.write([combination , ":", `${specName} ${statusMark} [${status}]`]);
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
let addCustomErrorToPrint = (error_object) => {
|
|
@@ -241,6 +242,8 @@ let getStatus = (status) => {
|
|
|
241
242
|
return chalk.green("✔");
|
|
242
243
|
case "failed":
|
|
243
244
|
return chalk.red("✘");
|
|
245
|
+
case "passed_with_skipped":
|
|
246
|
+
return chalk.blueBright("✔");
|
|
244
247
|
default:
|
|
245
248
|
return chalk.blue(`[${status}]`);
|
|
246
249
|
}
|
|
@@ -3,10 +3,10 @@ const syncSpecsLogs = require('./sync/syncSpecsLogs'),
|
|
|
3
3
|
specDetails = require('./sync/failedSpecsDetails'),
|
|
4
4
|
specsSummary = require('./sync/specsSummary');
|
|
5
5
|
|
|
6
|
-
exports.pollBuildStatus = (bsConfig, buildDetails) => {
|
|
6
|
+
exports.pollBuildStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
|
|
7
7
|
let customErrorsToPrint;
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
|
-
syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails).then((data) => {
|
|
9
|
+
syncSpecsLogs.printSpecsStatus(bsConfig, buildDetails, rawArgs, buildReportData).then((data) => {
|
|
10
10
|
if(data.customErrorsToPrint && data.customErrorsToPrint.length > 0) {
|
|
11
11
|
customErrorsToPrint = data.customErrorsToPrint;
|
|
12
12
|
}
|
package/bin/helpers/utils.js
CHANGED
|
@@ -182,7 +182,7 @@ exports.setParallels = (bsConfig, args, numOfSpecs) => {
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs) => {
|
|
185
|
+
exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs, buildReportData) => {
|
|
186
186
|
let expectedCharLength = specFiles.join("").length + Constants.METADATA_CHAR_BUFFER_PER_SPEC * specFiles.length;
|
|
187
187
|
let parallels = bsConfig.run_settings.parallels;
|
|
188
188
|
let combinations = this.getBrowserCombinations(bsConfig).length;
|
|
@@ -196,7 +196,7 @@ exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs) => {
|
|
|
196
196
|
Constants.userMessages.SPEC_LIMIT_WARNING,
|
|
197
197
|
Constants.messageTypes.WARNING,
|
|
198
198
|
null,
|
|
199
|
-
|
|
199
|
+
buildReportData,
|
|
200
200
|
rawArgs
|
|
201
201
|
);
|
|
202
202
|
}
|
|
@@ -371,6 +371,36 @@ exports.setRecordCaps = (bsConfig, args) => {
|
|
|
371
371
|
bsConfig.run_settings["projectId"] = this.setProjectId(bsConfig, args);
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
exports.verifyNodeVersionOption = () => {
|
|
375
|
+
let nvOptionsSet = (this.searchForOption('-nv') || this.searchForOption('--nv'));
|
|
376
|
+
let nodeVersionHyphenLocationOptionsSet = (this.searchForOption('-node-version') || this.searchForOption('--node-version'));
|
|
377
|
+
let nodeVersionOptionsSet = (this.searchForOption('-nodeVersion') || this.searchForOption('--nodeVersion'));
|
|
378
|
+
return (nvOptionsSet || nodeVersionHyphenLocationOptionsSet || nodeVersionOptionsSet);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
exports.setNodeVersion = (bsConfig, args) => {
|
|
382
|
+
let userProvidedNodeVersion = this.verifyNodeVersionOption();
|
|
383
|
+
bsConfig.run_settings.userProvidedNodeVersion = (userProvidedNodeVersion || (!this.isUndefined(bsConfig.run_settings.nodeVersion)) || (!this.isUndefined(bsConfig.run_settings.nodeversion)));
|
|
384
|
+
|
|
385
|
+
if (bsConfig.run_settings.userProvidedNodeVersion) {
|
|
386
|
+
if(!this.isUndefined(args.nodeVersion)) {
|
|
387
|
+
bsConfig.run_settings.nodeVersion = args.nodeVersion;
|
|
388
|
+
} else if (!this.isUndefined(bsConfig.run_settings.nodeversion)) {
|
|
389
|
+
bsConfig.run_settings.nodeVersion = bsConfig.run_settings.nodeversion;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (this.isUndefined(bsConfig.run_settings.nodeVersion)) {
|
|
394
|
+
bsConfig.run_settings.nodeVersion = usageReporting.get_version('node') || '';
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (bsConfig.run_settings.nodeVersion && typeof(bsConfig.run_settings.nodeVersion) === 'string' && bsConfig.run_settings.nodeVersion.charAt(0).toLowerCase() === 'v') {
|
|
398
|
+
bsConfig.run_settings.nodeVersion = bsConfig.run_settings.nodeVersion.substr(1);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
logger.debug(`Setting nodeVersion = ${bsConfig.run_settings.nodeVersion}`);
|
|
402
|
+
}
|
|
403
|
+
|
|
374
404
|
// specs can be passed from bstack configuration file
|
|
375
405
|
// specs can be passed via command line args as a string
|
|
376
406
|
// command line args takes precedence over config
|
|
@@ -715,7 +745,7 @@ exports.setLocalMode = (bsConfig, args) => {
|
|
|
715
745
|
}
|
|
716
746
|
};
|
|
717
747
|
|
|
718
|
-
exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
748
|
+
exports.setupLocalTesting = (bsConfig, args, rawArgs, buildReportData) => {
|
|
719
749
|
return new Promise(async (resolve, reject) => {
|
|
720
750
|
if( bsConfig['connection_settings'] && bsConfig['connection_settings']['local'] && String(bsConfig['connection_settings']['local']) === "true" ){
|
|
721
751
|
let localBinaryRunning = await this.checkLocalBinaryRunning(bsConfig, bsConfig['connection_settings']['local_identifier']);
|
|
@@ -751,7 +781,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
|
751
781
|
message,
|
|
752
782
|
Constants.messageTypes.ERROR,
|
|
753
783
|
errorCode,
|
|
754
|
-
|
|
784
|
+
buildReportData,
|
|
755
785
|
rawArgs
|
|
756
786
|
);
|
|
757
787
|
reject(Constants.userMessages.LOCAL_START_FAILED);
|
|
@@ -766,7 +796,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
|
766
796
|
});
|
|
767
797
|
};
|
|
768
798
|
|
|
769
|
-
exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
|
|
799
|
+
exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs, buildReportData) => {
|
|
770
800
|
return new Promise(async (resolve, reject) => {
|
|
771
801
|
if (!this.isUndefined(bs_local) && bs_local.isRunning() && bsConfig['connection_settings'] && bsConfig['connection_settings']['local_mode'].toLowerCase() != "always-on") {
|
|
772
802
|
let that = this;
|
|
@@ -783,7 +813,7 @@ exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
|
|
|
783
813
|
message,
|
|
784
814
|
Constants.messageTypes.ERROR,
|
|
785
815
|
errorCode,
|
|
786
|
-
|
|
816
|
+
buildReportData,
|
|
787
817
|
rawArgs
|
|
788
818
|
);
|
|
789
819
|
resolve(Constants.userMessages.LOCAL_STOP_FAILED);
|
|
@@ -1089,7 +1119,7 @@ exports.setDebugMode = (args) => {
|
|
|
1089
1119
|
}
|
|
1090
1120
|
|
|
1091
1121
|
|
|
1092
|
-
exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
|
|
1122
|
+
exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs, buildReportData = null) => {
|
|
1093
1123
|
let that = this;
|
|
1094
1124
|
return new Promise(function (resolve, reject) {
|
|
1095
1125
|
let url = config.buildStopUrl + buildId;
|
|
@@ -1152,7 +1182,7 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
|
|
|
1152
1182
|
errorCode = 'api_failed_build_stop';
|
|
1153
1183
|
logger.info(message);
|
|
1154
1184
|
} finally {
|
|
1155
|
-
that.sendUsageReport(bsConfig, args, message, messageType, errorCode,
|
|
1185
|
+
that.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
1156
1186
|
}
|
|
1157
1187
|
}
|
|
1158
1188
|
resolve();
|
|
@@ -1160,12 +1190,13 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
|
|
|
1160
1190
|
});
|
|
1161
1191
|
}
|
|
1162
1192
|
|
|
1163
|
-
exports.setProcessHooks = (buildId, bsConfig, bsLocal, args) => {
|
|
1193
|
+
exports.setProcessHooks = (buildId, bsConfig, bsLocal, args, buildReportData) => {
|
|
1164
1194
|
let bindData = {
|
|
1165
1195
|
buildId: buildId,
|
|
1166
1196
|
bsConfig: bsConfig,
|
|
1167
1197
|
bsLocalInstance: bsLocal,
|
|
1168
|
-
args: args
|
|
1198
|
+
args: args,
|
|
1199
|
+
buildReportData: buildReportData
|
|
1169
1200
|
}
|
|
1170
1201
|
process.on('SIGINT', processExitHandler.bind(this, bindData));
|
|
1171
1202
|
process.on('SIGTERM', processExitHandler.bind(this, bindData));
|
|
@@ -1175,8 +1206,8 @@ exports.setProcessHooks = (buildId, bsConfig, bsLocal, args) => {
|
|
|
1175
1206
|
|
|
1176
1207
|
async function processExitHandler(exitData){
|
|
1177
1208
|
logger.warn(Constants.userMessages.PROCESS_KILL_MESSAGE);
|
|
1178
|
-
await this.stopBrowserStackBuild(exitData.bsConfig, exitData.args, exitData.buildId);
|
|
1179
|
-
await this.stopLocalBinary(exitData.bsConfig, exitData.bsLocalInstance, exitData.args);
|
|
1209
|
+
await this.stopBrowserStackBuild(exitData.bsConfig, exitData.args, exitData.buildId, null, exitData.buildReportData);
|
|
1210
|
+
await this.stopLocalBinary(exitData.bsConfig, exitData.bsLocalInstance, exitData.args, null, exitData.buildReportData);
|
|
1180
1211
|
process.exit(0);
|
|
1181
1212
|
}
|
|
1182
1213
|
|
|
@@ -1202,3 +1233,24 @@ exports.getVideoConfig = (cypressJson) => {
|
|
|
1202
1233
|
logger.debug(`Setting videoUploadOnPasses = ${conf.videoUploadOnPasses}`);
|
|
1203
1234
|
return conf;
|
|
1204
1235
|
}
|
|
1236
|
+
|
|
1237
|
+
exports.getMajorVersion = (version) => {
|
|
1238
|
+
try {
|
|
1239
|
+
if (!version || !version.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)) {
|
|
1240
|
+
return null;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
const matches = version.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)
|
|
1244
|
+
if(matches && matches.length >= 2) {
|
|
1245
|
+
if (!matches[1]) {
|
|
1246
|
+
return matches[0];
|
|
1247
|
+
}
|
|
1248
|
+
return matches[1].replace('.','');
|
|
1249
|
+
} else {
|
|
1250
|
+
return null;
|
|
1251
|
+
}
|
|
1252
|
+
} catch(error) {
|
|
1253
|
+
logger.debug(`Some Error occurred while fetching major version of ${version}. Returning null. Error Details: ${error}`)
|
|
1254
|
+
return null;
|
|
1255
|
+
}
|
|
1256
|
+
}
|