Skip to content

Commit 5753ad2

Browse files
committed
fix diff creation
1 parent 45ff15e commit 5753ad2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/devextreme-cli/testing/utils/imageComparator.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ async function compareImages({ imageBuffer, snapshotPath, diffPath, threshold =
1313
ensureDirSync(path.dirname(snapshotPath));
1414
ensureDirSync(path.dirname(diffPath));
1515

16-
// If no snapshot exists, save one and return
1716
if (!fs.existsSync(snapshotPath)) {
1817
fs.writeFileSync(snapshotPath, imageBuffer);
1918
return { equal: true, created: true };
2019
}
21-
22-
// Write current image to temp file for diffing
20+
2321
const tempPath = path.join(os.tmpdir(), `current-${Date.now()}.png`);
2422
fs.writeFileSync(tempPath, imageBuffer);
2523

@@ -34,8 +32,18 @@ async function compareImages({ imageBuffer, snapshotPath, diffPath, threshold =
3432
diff: diffPath,
3533
highlightColor: '#ff00ff'
3634
}, (diffErr) => {
37-
fs.unlinkSync(tempPath); // Clean up temp file
38-
if (diffErr) return reject(diffErr);
35+
fs.unlinkSync(tempPath);
36+
37+
if (diffErr) {
38+
console.error('Error creating diff:', diffErr);
39+
return reject(diffErr);
40+
}
41+
42+
if (!fs.existsSync(diffPath)) {
43+
console.error('Diff file was not created at:', diffPath);
44+
return reject(new Error('Diff file not created'));
45+
}
46+
3947
resolve({ equal: false, created: false });
4048
});
4149
} else {

0 commit comments

Comments
 (0)