|
@@ -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 }` );
|
|
|
|
|
|
}
|
|
|
|