Could someone please help me with below,
Context: I would like to compare 2 PNG's using task and verify if there is any difference but while executing the task is never ending even though it has timeout. I have used below attached image for reference.
Task:
on('task', {
png({image1Path, image2Path}) {
const image1 = fs.readFileSync(image1Path);
const image2 = fs.readFileSync(image2Path);
const img1 = PNG.sync.read(image1);
const img2 = PNG.sync.read(image2);
const { width, height } = img1;
const diff = new PNG({ width, height });
pixelmatch(img1.data, img2.data, diff.data, width, height, {
threshold: 0.1,
});
fs.writeFileSync("diff.png", PNG.sync.write(diff));
return diff;
}
});
Code:
cy.task("png", {
image1Path: "cypress/downloads/sample.png",
image2Path: "cypress/downloads/sample.png",
},{ timeout: 50000 }).then((textOrNull) => {
expect(textOrNull).to.equal(0);