/
table.js
61 lines (61 loc) · 2.07 KB
/
table.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
}
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
}
Object.defineProperty(exports, "__esModule", { value: true });
const cli_table3_1 = __importDefault(require("cli-table3"));
const moment = __importStar(require("moment"));
function prettyPrintExecution(execution) {
let planTable = new cli_table3_1.default({
head: [],
style: {
head: [],
border: [],
},
colWidths: [15, 30, 15, 13, 15, 20, 17, 130],
wordWrap: true,
});
planTable.push([
'Plan Name:',
execution.plan.name,
'Status:',
execution.success ? 'Passed' : 'Failed',
'Duration:',
moment.utc(execution.stop_time - execution.start_time).format('HH:mm:ss'),
'mabl App Link:',
execution.plan.app_href,
]);
let journeyTable = new cli_table3_1.default({
head: ['Browser', 'Status', 'Journey Name', 'Duration', 'mabl App Link'],
style: {
head: [],
border: [],
},
colWidths: [10, 15, 27, 15, 160],
wordWrap: true,
});
execution.journey_executions.forEach(jE => {
let journey = execution.journeys.find(journey => journey.id === jE.journey_id);
journeyTable.push([
jE.browser_type,
jE.success ? 'Passed' : 'Failed',
journey ? journey.name : jE.journey_id,
moment.utc(jE.stop_time - jE.start_time).format('HH:mm:ss'),
jE.app_href,
]);
});
outputTable(planTable);
outputTable(journeyTable);
}
exports.prettyPrintExecution = prettyPrintExecution;
function outputTable(table) {
let tableAsString = table.toString().replace(/[\r\n]+/, '\n ');
console.log(tableAsString);
}