MCPcopy Index your code
hub / github.com/callstack/agent-device / formatScreenshotDiffStatusLines

Function formatScreenshotDiffStatusLines

src/utils/output.ts:328–352  ·  view source on GitHub ↗
(data: ScreenshotDiffResult, useColor: boolean)

Source from the content-addressed store, hash-verified

326}
327
328function formatScreenshotDiffStatusLines(data: ScreenshotDiffResult, useColor: boolean): string[] {
329 if (data.match === true) {
330 const indicator = useColor ? colorize('✓', 'green') : '✓';
331 return [`${indicator} Screenshots match.`];
332 }
333
334 const dimensionMismatch = data.dimensionMismatch;
335 const indicator = useColor ? colorize('✗', 'red') : '✗';
336 if (dimensionMismatch) {
337 const expected = dimensionMismatch.expected;
338 const actual = dimensionMismatch.actual;
339 return [
340 `${indicator} Screenshots have different dimensions: ` +
341 `expected ${expected?.width}x${expected?.height}, ` +
342 `got ${actual?.width}x${actual?.height}`,
343 ];
344 }
345
346 const differentPixels = toNumber(data.differentPixels);
347 const mismatchPercentage = toNumber(data.mismatchPercentage);
348 const pctLabel =
349 mismatchPercentage === 0 && differentPixels > 0 ? '<0.01' : String(mismatchPercentage);
350 const summary = `${pctLabel}% pixels differ`;
351 return [`${indicator} ${useColor ? colorize(summary, 'red') : summary}`];
352}
353
354function formatScreenshotDiffArtifactLines(
355 data: ScreenshotDiffResult,

Callers 1

formatScreenshotDiffTextFunction · 0.85

Calls 2

colorizeFunction · 0.85
toNumberFunction · 0.85

Tested by

no test coverage detected