Browse Source

Puppeteer: Cleanup (#25414)

Levi Pesin 2 years ago
parent
commit
43a4c84ec4
2 changed files with 9 additions and 12 deletions
  1. 0 1
      .github/workflows/ci.yml
  2. 9 11
      test/e2e/puppeteer.js

+ 0 - 1
.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

+ 9 - 11
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 }` );
 
 			}