docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a screenshot comparison utility that can compare two images and generate visual difference reports. The tool should support comparing PNG images and producing visual outputs that highlight the differences between them.
Create a function compareScreenshots that:
mismatchedPixels: number of pixels that differtotalPixels: total number of pixels comparedpercentDifference: percentage of pixels that differThe visual diff image should:
Create a test file compare.test.js with the following test cases:
Test 1: Identical Images @test
// Compare an image with itself
// Expected: 0 mismatched pixels, 0% differenceTest 2: Different Images @test
// Compare two different images of the same size
// Expected: mismatchedPixels > 0, percentDifference > 0
// A diff image should be generatedTest 3: Statistics Accuracy @test
// Verify that percentDifference = (mismatchedPixels / totalPixels) * 100
// Verify that totalPixels = width * heightProvides pixel-level image comparison capabilities for visual regression testing.
Provides PNG encoding and decoding functionality for reading and writing PNG images.