-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
30 lines (22 loc) · 2.58 KB
/
test.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
let chalk = require('chalk');
// console.log(chalk.blue('Hello world!'));
let data =[{"paymentMode":"DC","timeTaken":14650,"testPassed":0,"totalTests":2,"averageTimePerTest":7325,"seamless":{"VISA":[{"status":true,"timeTaken":6473,"steps":[{"step":"PG page loaded","status":true,"logs":""},{"step":"OTP submitted","status":true,"logs":""},{"step":"Response validated","status":true,"logs":""}]}]},"nonseamless":{"VISA":[{"status":true,"timeTaken":8177,"steps":[{"step":"UPI loader page loaded","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"PG page loaded","status":true,"logs":""},{"step":"OTP submitted","status":true,"logs":""},{"step":"Response validated","status":true,"logs":""}]}]}},{"paymentMode":"CC","timeTaken":16236,"testPassed":2,"totalTests":2,"averageTimePerTest":8118,"seamless":{"Mastercard":[{"status":true,"timeTaken":7664,"steps":[{"step":"PG page loaded","status":true,"logs":""},{"step":"OTP submitted","status":true,"logs":""},{"step":"Response validated","status":true,"logs":""}]}]},"nonseamless":{"Mastercard":[{"status":true,"timeTaken":8572,"steps":[{"step":"UPI loader page loaded","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"Credentials submitted","status":true,"logs":""},{"step":"PG page loaded","status":true,"logs":""},{"step":"OTP submitted","status":true,"logs":""},{"step":"Response validated","status":true,"logs":""}]}]}}]
let tables = []
for (test of data){
let status;
if(test.testPassed == 0) status = chalk.redBright("FAILED");
else if(test.testPassed < test.totalTests) status = chalk.yellowBright("PARTIALLY PASSED");
else status = chalk.greenBright("PASSED");
tables.push([test.paymentMode,status,`${test.testPassed}/${test.totalTests}`,`${test.timeTaken}`])
}
var Table = require('cli-table');
// instantiate
var table = new Table({
head: ['Mode', 'Status', 'Test passed', 'Duration (ms)'],
chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗'
, 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝'
, 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼'
, 'right': '║' , 'right-mid': '╢' , 'middle': '│' }
});
table.push(...tables);
console.log(table.toString());