diff --git a/test/regression.js b/test/regression.js index c76e3edd2..926dc7b0c 100644 --- a/test/regression.js +++ b/test/regression.js @@ -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, ); @@ -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',