Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puppeteer E2E test: Cleanup #25414

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 9 additions & 11 deletions test/e2e/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 }` );

}

Expand Down