(data: ScreenshotDiffResult, useColor: boolean)
| 326 | } |
| 327 | |
| 328 | function 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 | |
| 354 | function formatScreenshotDiffArtifactLines( |
| 355 | data: ScreenshotDiffResult, |
no test coverage detected