Skip to content

Commit 39b1575

Browse files
committed
Changes in CLI output and prettify it.
1 parent 6c2ea52 commit 39b1575

File tree

3 files changed

+78
-21
lines changed

3 files changed

+78
-21
lines changed

commands/utils/dom.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ const fs = require('fs');
33
const path = require('path')
44
const formData = require('form-data');
55
const { JSDOM } = require("jsdom");
6+
const Table = require('cli-table3');
67
var { constants } = require('./constants');
7-
const { getLastCommit } = require('./git')
8+
const { getLastCommit } = require('./git');
89

910
var INTERVAL = 2000
1011
const MAX_INTERVAL = 512000
@@ -88,22 +89,41 @@ async function shortPolling(buildId, retries = 0, options) {
8889
if (response.data.buildStatus === 'completed') {
8990
console.log('[smartui] Build successful\n');
9091
console.log('[smartui] Build details:\n',
91-
// 'Build URL: ', response.data.buildId, '\n',
92+
'Build URL: ', response.data.buildURL, '\n',
9293
'Build Name: ', response.data.buildName, '\n',
93-
'Total Screenshots: ', response.data.screenshots.length, '\n',
94+
'Total Screenshots: ', response.data.totalScreenshots, '\n',
9495
'Approved: ', response.data.buildResults.approved, '\n',
9596
'Changes found: ', response.data.buildResults.changesFound, '\n'
9697
);
97-
98-
response.data.screenshots.forEach(screenshot => {
99-
console.log(screenshot.storyName, ' | Mis-match: ', screenshot.mismatchPercentage);
100-
});
101-
98+
99+
if (response.data.screenshots && response.data.screenshots.length > 0) {
100+
import('chalk').then((chalk) => {
101+
const table = new Table({
102+
head: [
103+
{content: chalk.default.white('Story'), hAlign: 'center'},
104+
{content: chalk.default.white('Mis-match %'), hAlign: 'center'},
105+
]
106+
});
107+
response.data.screenshots.forEach(screenshot => {
108+
let mismatch = screenshot.mismatchPercentage
109+
table.push([
110+
chalk.default.yellow(screenshot.storyName),
111+
mismatch > 0 ? chalk.default.red(mismatch) : chalk.default.green(mismatch)
112+
])
113+
});
114+
console.log(table.toString());
115+
})
116+
} else {
117+
if (response.data.baseline) {
118+
console.log('No comparisons run. This is a baseline build.');
119+
}
120+
console.log('No comparisons run. No screenshot in the current build has the corresponding screenshot in baseline build.');
121+
}
102122
return;
103123
} else {
104124
if (response.data.screenshots && response.data.screenshots.length > 0) {
105-
// TODO: show Screenshots processed 8/10
106-
console.log('[smartui] Screenshots processed: ', response.data.screenshots.length)
125+
// TODO: show Screenshots processed current/total
126+
console.log('[smartui] Screenshots compared: ', response.data.screenshots.length)
107127
}
108128
}
109129
}
@@ -125,8 +145,7 @@ async function shortPolling(buildId, retries = 0, options) {
125145
console.log('[smartui] Please check the build status on LambdaTest SmartUI.');
126146
return;
127147
}
128-
129-
console.log('here2');
148+
130149
setTimeout(function () {
131150
shortPolling(buildId, retries+1, options);
132151
}, 2000);

package-lock.json

Lines changed: 45 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"dependencies": {
2727
"axios": "^1.2.2",
2828
"browserless": "^9.8.0",
29+
"chalk": "^5.2.0",
30+
"cli-table3": "^0.6.3",
2931
"commander": "^9.5.0",
3032
"finalhandler": "^1.2.0",
3133
"form-data": "^4.0.0",

0 commit comments

Comments
 (0)