Skip to content

Commit

Permalink
test: print diff
Browse files Browse the repository at this point in the history
  • Loading branch information
etowahadams committed Nov 16, 2023
1 parent a220225 commit 25eb75d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export function isPngSame(newImg: Buffer, oldImg: Buffer) {
const img1 = PNG.sync.read(newImg);
const img2 = PNG.sync.read(oldImg);
// check if the images have the same dimensions
console.warn(img1.width, img2.width, img1.height, img2.height)
if (img1.width !== img2.width || img1.height !== img2.height) return false;

console.warn('same size');

const { width, height } = img1;
const diff = new PNG({ width, height });
const pixeldifference = pixelmatch(img1.data, img2.data, diff.data, width, height, { threshold: 0.1 });
console.warn(`pixel difference: ${pixeldifference}`);
// only write to file if there is a difference in the images
return pixeldifference === 0;
}
Expand Down

0 comments on commit 25eb75d

Please sign in to comment.