-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff.js
29 lines (27 loc) · 855 Bytes
/
diff.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
const looksSame = require('looks-same');
const { baseUrl, pages, breakpoints } = require('./pages.json');
breakpoints.forEach(({ width }) => {
pages.forEach(({ name, url }) => {
var updated = `./screenshots/${name}-${width}.png`;
var baseline = `./screenshots/${name}-${width}-baseline.png`;
var diff = `./screenshots/${name}-${width}-diff.png`;
if (fs.existsSync(baseline) && fs.existsSync(updated)) {
looksSame.createDiff(
{
reference: baseline,
current: updated,
diff: diff,
highlightColor: '#ff00ff',
strict: false,
tolerance: 5
},
function(error) {
if (error) console.warn(error);
}
);
} else {
console.log(`Missing the baseline or updated image for "${name}".`);
}
});
});