From 226831440ec5e198b36b08fdbd21e349411da786 Mon Sep 17 00:00:00 2001 From: Levi Pesin <35454228+LeviPesin@users.noreply.github.com> Date: Fri, 3 Feb 2023 03:25:40 +1100 Subject: [PATCH] Puppeteer: Cleanup --- .github/workflows/ci.yml | 1 - test/e2e/puppeteer.js | 20 +++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8bac271f4951b..698b8f5efd0ad3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,6 @@ jobs: CI: [ 0, 1, 2, 3, 4, 5, 6, 7 ] env: CI: ${{ matrix.CI }} - FORCE_COLOR: 1 steps: - name: Git checkout uses: actions/checkout@v2 diff --git a/test/e2e/puppeteer.js b/test/e2e/puppeteer.js index a676a30eb19d07..c6640a42e153f8 100644 --- a/test/e2e/puppeteer.js +++ b/test/e2e/puppeteer.js @@ -59,7 +59,7 @@ const chromiumChannel = 'stable'; // stable -> beta -> dev -> canary (Mac and Wi const port = 1234; const pixelThreshold = 0.1; // threshold error in one pixel -const maxFailedPixels = 0.05; // at most 5% failed pixels +const maxDifferentPixels = 0.05; // at most 5% different pixels const networkTimeout = 90; // 90 seconds, set to 0 to disable const renderTimeout = 4.5; // 4.5 seconds, set to 0 to disable @@ -449,15 +449,13 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot const actual = screenshot.bitmap; const diff = screenshot.clone(); - let numFailedPixels; + let numDifferentPixels; try { - numFailedPixels = pixelmatch( expected.bitmap.data, actual.data, diff.bitmap.data, actual.width, actual.height, { + numDifferentPixels = pixelmatch( expected.bitmap.data, actual.data, diff.bitmap.data, actual.width, actual.height, { threshold: pixelThreshold, - alpha: 0.2, - diffMask: process.env.FORCE_COLOR === '0', - diffColor: process.env.FORCE_COLOR === '0' ? [ 255, 255, 255 ] : [ 255, 0, 0 ] + alpha: 0.2 } ); } catch { @@ -466,19 +464,19 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot } - numFailedPixels /= actual.width * actual.height; + numDifferentPixels /= actual.width * actual.height; /* Print results */ - const percFailedPixels = 100 * numFailedPixels; + const differentPixels = 100 * numDifferentPixels; - if ( numFailedPixels < maxFailedPixels ) { + if ( numDifferentPixels < maxDifferentPixels ) { - console.green( `Diff ${ percFailedPixels.toFixed( 1 ) }% in file: ${ file }` ); + console.green( `Diff ${ differentPixels.toFixed( 1 ) }% in file: ${ file }` ); } else { - throw new Error( `Diff wrong in ${ percFailedPixels.toFixed( 1 ) }% of pixels in file: ${ file }` ); + throw new Error( `Diff wrong in ${ differentPixels.toFixed( 1 ) }% of pixels in file: ${ file }` ); }