diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 698b8f5efd0ad3..93946cee2f20a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,6 +77,12 @@ 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 + if-no-files-found: ignore e2e-cov: name: "Examples ready for release" diff --git a/.gitignore b/.gitignore index 6895a6a437988c..50df59a8212b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/test/e2e/puppeteer.js b/test/e2e/puppeteer.js index c6640a42e153f8..47b05d11a213b8 100644 --- a/test/e2e/puppeteer.js +++ b/test/e2e/puppeteer.js @@ -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 {} + try { await fs.mkdir( 'test/e2e/output-screenshots' ); } catch {} + /* Find files */ const isMakeScreenshot = process.argv[ 2 ] === '--make'; @@ -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 }` ); } @@ -460,6 +466,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 }` ); } @@ -476,6 +484,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 ${ differentPixels.toFixed( 1 ) }% of pixels in file: ${ file }` ); }