Skip to content

Commit 7a9e5aa

Browse files
committed
Don't run pixelmatch if image dims don't match
1 parent 584756e commit 7a9e5aa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/image/compare_pixels_test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,22 @@ for (let mockName of allMockList) {
126126

127127
const img0 = PNG.sync.read(fs.readFileSync(base));
128128
const img1 = PNG.sync.read(fs.readFileSync(test));
129+
let dimensionMismatch = false;
129130
for (const key of ['height', 'width']) {
130131
const length0 = img0[key];
131132
const length1 = img1[key];
132133
if (length0 !== length1) {
133134
console.error(key + 's do not match: ' + length0 + ' vs ' + length1);
134-
failed.add(mockName);
135+
dimensionMismatch = true;
135136
}
136137
}
137138

139+
if (dimensionMismatch) {
140+
fs.copyFileSync(test, diff);
141+
failed.add(mockName);
142+
continue;
143+
}
144+
138145
if (virtualWebgl) {
139146
if (flakyListVirtualWebgl.has(mockName)) threshold = 0.7;
140147
else threshold = Math.max(0.4, threshold);

0 commit comments

Comments
 (0)