Skip to content

Commit 820a3ec

Browse files
resolved all bugs
1 parent 78900f6 commit 820a3ec

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/lib/ctx.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,16 @@ export default (options: Record<string, string>): Context => {
4444
ignoreStripExtension = options.removeExtensions || false
4545
ignoreFilePattern = options.ignoreDir || []
4646

47-
if(options.fetchResults){
47+
if (options.fetchResults) {
48+
if (options.fetchResults !== true && !options.fetchResults.endsWith('.json')) {
49+
console.error("Error: The file extension for --fetch-results must be .json");
50+
process.exit(1);
51+
}
4852
fetchResultObj = true
4953
fetchResultsFileObj = options.fetchResults === true ? 'results.json' : options.fetchResults;
54+
} else {
55+
fetchResultObj = false
56+
fetchResultsFileObj = ''
5057
}
5158
} catch (error: any) {
5259
console.log(`[smartui] Error: ${error.message}`);

src/lib/utils.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'fs'
22
import { Context } from '../types.js'
33
import { chromium, firefox, webkit, Browser } from '@playwright/test'
44
import constants from './constants.js';
5+
import chalk from 'chalk';
56

67
let isPollingActive = false;
78

@@ -270,16 +271,23 @@ export async function startPolling(ctx: Context, task: any): Promise<void> {
270271

271272
// Display summary
272273
ctx.log.info(
273-
`\nSummary of Mismatches:\n` +
274-
`Total Variants with Mismatches: ${totalVariantsWithMismatches} out of ${totalVariants}\n` +
275-
`Total Screenshots with Mismatches: ${totalScreenshotsWithMismatches} out of ${totalScreenshots}\n` +
276-
`Branch Name: ${resp.build.branch}\n` +
277-
`Project Name: ${resp.project.name}\n` +
278-
`Build ID: ${resp.build.build_id}\n`
279-
);
274+
chalk.green.bold(
275+
`\nSummary of Mismatches:\n` +
276+
`${chalk.yellow('Total Variants with Mismatches:')} ${chalk.white(totalVariantsWithMismatches)} out of ${chalk.white(totalVariants)}\n` +
277+
`${chalk.yellow('Total Screenshots with Mismatches:')} ${chalk.white(totalScreenshotsWithMismatches)} out of ${chalk.white(totalScreenshots)}\n` +
278+
`${chalk.yellow('Branch Name:')} ${chalk.white(resp.build.branch)}\n` +
279+
`${chalk.yellow('Project Name:')} ${chalk.white(resp.project.name)}\n` +
280+
`${chalk.yellow('Build ID:')} ${chalk.white(resp.build.build_id)}\n`
281+
)
282+
);
280283
}
281284
} catch (error: any) {
282-
ctx.log.error(`Error fetching screenshot data: ${error.message}`);
285+
if (error.message.includes('ENOTFOUND')) {
286+
ctx.log.error('Error: Network error occurred while fetching build results. Please check your connection and try again.');
287+
clearInterval(intervalId);
288+
} else {
289+
ctx.log.error(`Error fetching screenshot data: ${error.message}`);
290+
}
283291
clearInterval(intervalId);
284292
isPollingActive = false;
285293
}

0 commit comments

Comments
 (0)