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: Show actual and difference screenshots #25410

Merged
merged 4 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ jobs:

- name: === E2E testing ===
run: npm run test-e2e
- name: Upload output screenshots
uses: actions/upload-artifact@v3
with:
name: Output screenshots
path: test/e2e/output-screenshots

e2e-cov:
name: "Examples ready for release"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ test/treeshake/index.bundle.min.js
test/treeshake/index-src.bundle.min.js
test/treeshake/stats.html
test/e2e/chromium
test/e2e/output-screenshots

**/node_modules
13 changes: 12 additions & 1 deletion test/e2e/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ process.on( 'SIGINT', () => close() );

async function main() {

/* Create output directories */

try { await fs.rm( 'test/e2e/output-screenshots', { recursive: true, force: true } ) } catch {}
Fixed Show fixed Hide fixed
try { await fs.mkdir( 'test/e2e/output-screenshots' ) } catch {}
Fixed Show fixed Hide fixed

/* Find files */

const isMakeScreenshot = process.argv[ 2 ] === '--make';
Expand Down Expand Up @@ -438,10 +443,11 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot

try {

expected = await jimp.read( `examples/screenshots/${ file }.jpg` );
expected = ( await jimp.read( `examples/screenshots/${ file }.jpg` ) ).quality( jpgQuality );

} catch {

await screenshot.writeAsync( `test/e2e/output-screenshots/${ file }-actual.jpg` );
throw new Error( `Screenshot does not exist: ${ file }` );

}
Expand All @@ -462,6 +468,8 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot

} catch {

await screenshot.writeAsync( `test/e2e/output-screenshots/${ file }-actual.jpg` );
await expected.writeAsync( `test/e2e/output-screenshots/${ file }-expected.jpg` );
throw new Error( `Image sizes does not match in file: ${ file }` );

}
Expand All @@ -478,6 +486,9 @@ async function makeAttempt( page, failedScreenshots, cleanPage, isMakeScreenshot

} else {

await screenshot.writeAsync( `test/e2e/output-screenshots/${ file }-actual.jpg` );
await expected.writeAsync( `test/e2e/output-screenshots/${ file }-expected.jpg` );
await diff.writeAsync( `test/e2e/output-screenshots/${ file }-diff.jpg` );
throw new Error( `Diff wrong in ${ percFailedPixels.toFixed( 1 ) }% of pixels in file: ${ file }` );

}
Expand Down