Skip to content

Commit

Permalink
ci: dont create diff png if no_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco committed Dec 25, 2023
1 parent 3d48f3a commit 1ab01a1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ const runTests = async (list) => {
await page.goto(`http://localhost:5000/optimized/${name}`);
const optimizedBufferPromise = page.screenshot(screenshotOptions);

const writeDiffs = process.env.NO_DIFF == null;
const diff = writeDiffs && new PNG({ width, height });
const originalPng = PNG.sync.read(originalBuffer);
const optimizedPng = PNG.sync.read(await optimizedBufferPromise);
const diff = new PNG({ width, height });
const matched = pixelmatch(
originalPng.data,
optimizedPng.data,
diff.data,
diff ? diff.data : null,
width,
height,
);
Expand All @@ -59,7 +60,7 @@ const runTests = async (list) => {
} else {
mismatched++;
console.error(`${name} is mismatched`);
if (process.env.NO_DIFF == null) {
if (diff) {
const file = path.join(
__dirname,
'regression-diffs',
Expand Down

0 comments on commit 1ab01a1

Please sign in to comment.