Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: organize golden files under __snapshots__ folder (#3494)
Pavel Feldman262e886940b9
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex e6279df909..1b6c40a509 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -46,8 +46,8 @@ jobs:- uses: actions/upload-artifact@v1if: failure()with:- name: ${{ matrix.browser }}-${{ matrix.os }}-output- path: test/output-${{ matrix.browser }}+ name: ${{ matrix.browser }}-${{ matrix.os }}-test-results+ path: test-results- uses: actions/upload-artifact@v1if: ${{ always() }}with:@@ -77,8 +77,8 @@ jobs:- uses: actions/upload-artifact@v1if: failure()with:- name: ${{ matrix.browser }}-mac-output- path: test/output-${{ matrix.browser }}+ name: ${{ matrix.browser }}-mac-test-results+ path: test-results- uses: actions/upload-artifact@v1if: ${{ always() }}with:@@ -112,8 +112,8 @@ jobs:- uses: actions/upload-artifact@v1if: failure()with:- name: ${{ matrix.browser }}-win-output- path: test/output-${{ matrix.browser }}+ name: ${{ matrix.browser }}-win-test-results+ path: test-results- uses: actions/upload-artifact@v1if: ${{ always() }}with:@@ -169,8 +169,8 @@ jobs:- uses: actions/upload-artifact@v1if: failure()with:- name: headful-${{ matrix.browser }}-linux-output- path: test/output-${{ matrix.browser }}+ name: headful-${{ matrix.browser }}-linux-test-results+ path: test-results- uses: actions/upload-artifact@v1if: ${{ always() }}with:@@ -207,8 +207,8 @@ jobs:- uses: actions/upload-artifact@v1if: failure()with:- name: wire-${{ matrix.browser }}-linux-output- path: test/output-${{ matrix.browser }}+ name: wire-${{ matrix.browser }}-linux-test-results+ path: test-results- uses: actions/upload-artifact@v1if: ${{ always() }}with:diff --git a/.gitignore b/.gitignoreindex 92cc44e8a6..657282ae6f 100644--- a/.gitignore+++ b/.gitignore@@ -1,7 +1,6 @@/node_modules/-/test/output-chromium-/test/output-firefox-/test/output-webkit+/test-results/+/test/coverage-report/test/test-user-data-dir*.local-browsers//.dev_profile*diff --git a/test/__snapshots__/chromium/oopif/chromium/screenshot-oopif.png b/test/__snapshots__/chromium/oopif/chromium/screenshot-oopif.pngnew file mode 100644index 0000000000..951e96f178Binary files /dev/null and b/test/__snapshots__/chromium/oopif/chromium/screenshot-oopif.png differdiff --git a/test/golden-chromium/screenshot-element-bounding-box.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-bounding-box.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-bounding-box.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-bounding-box.pngdiff --git a/test/golden-chromium/screenshot-element-fractional-offset.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-fractional-offset.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-fractional-offset.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-fractional-offset.pngdiff --git a/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-fractional.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-fractional.pngnew file mode 100644index 0000000000..bd1810da8bBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-fractional.png differdiff --git a/test/golden-chromium/screenshot-element-larger-than-viewport.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-larger-than-viewport.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-larger-than-viewport.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-larger-than-viewport.pngdiff --git a/test/golden-chromium/screenshot-element-mobile-dsf.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-mobile-dsf.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-mobile-dsf.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-mobile-dsf.pngdiff --git a/test/golden-chromium/screenshot-element-mobile.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-mobile.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-mobile.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-mobile.pngdiff --git a/test/golden-chromium/screenshot-element-padding-border.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-padding-border.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-padding-border.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-padding-border.pngdiff --git a/test/golden-chromium/screenshot-element-rotate.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-rotate.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-rotate.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-rotate.pngdiff --git a/test/golden-chromium/screenshot-element-scrolled-into-view.png b/test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-scrolled-into-view.pngsimilarity index 100%rename from test/golden-chromium/screenshot-element-scrolled-into-view.pngrename to test/__snapshots__/elementhandle-screenshot/chromium/screenshot-element-scrolled-into-view.pngdiff --git a/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-bounding-box.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-bounding-box.pngnew file mode 100644index 0000000000..9e208f86d8Binary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-bounding-box.png differdiff --git a/test/golden-firefox/screenshot-element-fractional-offset.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-fractional-offset.pngsimilarity index 100%rename from test/golden-firefox/screenshot-element-fractional-offset.pngrename to test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-fractional-offset.pngdiff --git a/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-fractional.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-fractional.pngnew file mode 100644index 0000000000..d1431bd91dBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-fractional.png differdiff --git a/test/golden-webkit/screenshot-element-larger-than-viewport.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-larger-than-viewport.pngsimilarity index 85%rename from test/golden-webkit/screenshot-element-larger-than-viewport.pngrename to test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-larger-than-viewport.pngindex 5fcdb92355..6d28cddcea 100644Binary files a/test/golden-webkit/screenshot-element-larger-than-viewport.png and b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-larger-than-viewport.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-padding-border.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-padding-border.pngnew file mode 100644index 0000000000..2b72c7528bBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-padding-border.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-rotate.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-rotate.pngnew file mode 100644index 0000000000..f391edcad9Binary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-rotate.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-scrolled-into-view.png b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-scrolled-into-view.pngnew file mode 100644index 0000000000..2b72c7528bBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/firefox/screenshot-element-scrolled-into-view.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-bounding-box.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-bounding-box.pngnew file mode 100644index 0000000000..ad6858bf2fBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-bounding-box.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-fractional-offset.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-fractional-offset.pngnew file mode 100644index 0000000000..ac79d2f938Binary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-fractional-offset.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-fractional.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-fractional.pngnew file mode 100644index 0000000000..03c539bc86Binary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-fractional.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-larger-than-viewport.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-larger-than-viewport.pngnew file mode 100644index 0000000000..aacf91548eBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-larger-than-viewport.png differdiff --git a/test/golden-webkit/screenshot-element-mobile-dsf.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-mobile-dsf.pngsimilarity index 100%rename from test/golden-webkit/screenshot-element-mobile-dsf.pngrename to test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-mobile-dsf.pngdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-mobile.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-mobile.pngnew file mode 100644index 0000000000..ad6858bf2fBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-mobile.png differdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-padding-border.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-padding-border.pngnew file mode 100644index 0000000000..4a1e362cdbBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-padding-border.png differdiff --git a/test/golden-firefox/screenshot-element-rotate.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-rotate.pngsimilarity index 100%rename from test/golden-firefox/screenshot-element-rotate.pngrename to test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-rotate.pngdiff --git a/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-scrolled-into-view.png b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-scrolled-into-view.pngnew file mode 100644index 0000000000..4a1e362cdbBinary files /dev/null and b/test/__snapshots__/elementhandle-screenshot/webkit/screenshot-element-scrolled-into-view.png differdiff --git a/test/__snapshots__/emulation-focus/chromium/grid-cell-0.png b/test/__snapshots__/emulation-focus/chromium/grid-cell-0.pngnew file mode 100644index 0000000000..ca5f8ec584Binary files /dev/null and b/test/__snapshots__/emulation-focus/chromium/grid-cell-0.png differdiff --git a/test/golden-chromium/screenshot-sanity.png b/test/__snapshots__/emulation-focus/chromium/screenshot-sanity.pngsimilarity index 100%rename from test/golden-chromium/screenshot-sanity.pngrename to test/__snapshots__/emulation-focus/chromium/screenshot-sanity.pngdiff --git a/test/__snapshots__/emulation-focus/firefox/grid-cell-0.png b/test/__snapshots__/emulation-focus/firefox/grid-cell-0.pngnew file mode 100644index 0000000000..370350757aBinary files /dev/null and b/test/__snapshots__/emulation-focus/firefox/grid-cell-0.png differdiff --git a/test/__snapshots__/emulation-focus/firefox/screenshot-sanity.png b/test/__snapshots__/emulation-focus/firefox/screenshot-sanity.pngnew file mode 100644index 0000000000..7b16493355Binary files /dev/null and b/test/__snapshots__/emulation-focus/firefox/screenshot-sanity.png differdiff --git a/test/__snapshots__/emulation-focus/webkit/grid-cell-0.png b/test/__snapshots__/emulation-focus/webkit/grid-cell-0.pngnew file mode 100644index 0000000000..117929e479Binary files /dev/null and b/test/__snapshots__/emulation-focus/webkit/grid-cell-0.png differdiff --git a/test/__snapshots__/emulation-focus/webkit/screenshot-sanity.png b/test/__snapshots__/emulation-focus/webkit/screenshot-sanity.pngnew file mode 100644index 0000000000..4cf1a338fcBinary files /dev/null and b/test/__snapshots__/emulation-focus/webkit/screenshot-sanity.png differdiff --git a/test/__snapshots__/page-screenshot/chromium/grid-cell-0.png b/test/__snapshots__/page-screenshot/chromium/grid-cell-0.pngnew file mode 100644index 0000000000..ca5f8ec584Binary files /dev/null and b/test/__snapshots__/page-screenshot/chromium/grid-cell-0.png differdiff --git a/test/golden-chromium/grid-cell-1.png b/test/__snapshots__/page-screenshot/chromium/grid-cell-1.pngsimilarity index 100%rename from test/golden-chromium/grid-cell-1.pngrename to test/__snapshots__/page-screenshot/chromium/grid-cell-1.pngdiff --git a/test/golden-chromium/screenshot-canvas.png b/test/__snapshots__/page-screenshot/chromium/screenshot-canvas.pngsimilarity index 100%rename from test/golden-chromium/screenshot-canvas.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-canvas.pngdiff --git a/test/golden-chromium/screenshot-clip-odd-size.png b/test/__snapshots__/page-screenshot/chromium/screenshot-clip-odd-size.pngsimilarity index 100%rename from test/golden-chromium/screenshot-clip-odd-size.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-clip-odd-size.pngdiff --git a/test/golden-chromium/screenshot-clip-rect.png b/test/__snapshots__/page-screenshot/chromium/screenshot-clip-rect.pngsimilarity index 100%rename from test/golden-chromium/screenshot-clip-rect.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-clip-rect.pngdiff --git a/test/golden-chromium/screenshot-device-scale-factor.png b/test/__snapshots__/page-screenshot/chromium/screenshot-device-scale-factor.pngsimilarity index 100%rename from test/golden-chromium/screenshot-device-scale-factor.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-device-scale-factor.pngdiff --git a/test/golden-chromium/screenshot-grid-fullpage.png b/test/__snapshots__/page-screenshot/chromium/screenshot-grid-fullpage.pngsimilarity index 100%rename from test/golden-chromium/screenshot-grid-fullpage.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-grid-fullpage.pngdiff --git a/test/golden-chromium/screenshot-iframe.png b/test/__snapshots__/page-screenshot/chromium/screenshot-iframe.pngsimilarity index 100%rename from test/golden-chromium/screenshot-iframe.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-iframe.pngdiff --git a/test/golden-chromium/screenshot-mobile-clip.png b/test/__snapshots__/page-screenshot/chromium/screenshot-mobile-clip.pngsimilarity index 100%rename from test/golden-chromium/screenshot-mobile-clip.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-mobile-clip.pngdiff --git a/test/golden-chromium/screenshot-mobile-fullpage.png b/test/__snapshots__/page-screenshot/chromium/screenshot-mobile-fullpage.pngsimilarity index 100%rename from test/golden-chromium/screenshot-mobile-fullpage.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-mobile-fullpage.pngdiff --git a/test/__snapshots__/page-screenshot/chromium/screenshot-mobile.png b/test/__snapshots__/page-screenshot/chromium/screenshot-mobile.pngnew file mode 100644index 0000000000..f18ddb47f3Binary files /dev/null and b/test/__snapshots__/page-screenshot/chromium/screenshot-mobile.png differdiff --git a/test/golden-chromium/screenshot-offscreen-clip.png b/test/__snapshots__/page-screenshot/chromium/screenshot-offscreen-clip.pngsimilarity index 100%rename from test/golden-chromium/screenshot-offscreen-clip.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-offscreen-clip.pngdiff --git a/test/__snapshots__/page-screenshot/chromium/screenshot-sanity.png b/test/__snapshots__/page-screenshot/chromium/screenshot-sanity.pngnew file mode 100644index 0000000000..122a4f0ae0Binary files /dev/null and b/test/__snapshots__/page-screenshot/chromium/screenshot-sanity.png differdiff --git a/test/golden-chromium/screenshot-translateZ.png b/test/__snapshots__/page-screenshot/chromium/screenshot-translateZ.pngsimilarity index 100%rename from test/golden-chromium/screenshot-translateZ.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-translateZ.pngdiff --git a/test/golden-chromium/screenshot-webgl.png b/test/__snapshots__/page-screenshot/chromium/screenshot-webgl.pngsimilarity index 100%rename from test/golden-chromium/screenshot-webgl.pngrename to test/__snapshots__/page-screenshot/chromium/screenshot-webgl.pngdiff --git a/test/golden-chromium/transparent.png b/test/__snapshots__/page-screenshot/chromium/transparent.pngsimilarity index 100%rename from test/golden-chromium/transparent.pngrename to test/__snapshots__/page-screenshot/chromium/transparent.pngdiff --git a/test/__snapshots__/page-screenshot/chromium/white.jpg b/test/__snapshots__/page-screenshot/chromium/white.jpgnew file mode 100644index 0000000000..0bc91643aaBinary files /dev/null and b/test/__snapshots__/page-screenshot/chromium/white.jpg differdiff --git a/test/__snapshots__/page-screenshot/firefox/grid-cell-0.png b/test/__snapshots__/page-screenshot/firefox/grid-cell-0.pngnew file mode 100644index 0000000000..370350757aBinary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/grid-cell-0.png differdiff --git a/test/__snapshots__/page-screenshot/firefox/grid-cell-1.png b/test/__snapshots__/page-screenshot/firefox/grid-cell-1.pngnew file mode 100644index 0000000000..55d6a44412Binary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/grid-cell-1.png differdiff --git a/test/golden-firefox/screenshot-canvas.png b/test/__snapshots__/page-screenshot/firefox/screenshot-canvas.pngsimilarity index 50%rename from test/golden-firefox/screenshot-canvas.pngrename to test/__snapshots__/page-screenshot/firefox/screenshot-canvas.pngindex dfafbda638..b0af90ae99 100644Binary files a/test/golden-firefox/screenshot-canvas.png and b/test/__snapshots__/page-screenshot/firefox/screenshot-canvas.png differdiff --git a/test/__snapshots__/page-screenshot/firefox/screenshot-clip-odd-size.png b/test/__snapshots__/page-screenshot/firefox/screenshot-clip-odd-size.pngnew file mode 100644index 0000000000..8e86dc9017Binary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/screenshot-clip-odd-size.png differdiff --git a/test/__snapshots__/page-screenshot/firefox/screenshot-clip-rect.png b/test/__snapshots__/page-screenshot/firefox/screenshot-clip-rect.pngnew file mode 100644index 0000000000..6459e3afe7Binary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/screenshot-clip-rect.png differdiff --git a/test/golden-firefox/screenshot-device-scale-factor.png b/test/__snapshots__/page-screenshot/firefox/screenshot-device-scale-factor.pngsimilarity index 100%rename from test/golden-firefox/screenshot-device-scale-factor.pngrename to test/__snapshots__/page-screenshot/firefox/screenshot-device-scale-factor.pngdiff --git a/test/__snapshots__/page-screenshot/firefox/screenshot-grid-fullpage.png b/test/__snapshots__/page-screenshot/firefox/screenshot-grid-fullpage.pngnew file mode 100644index 0000000000..e87220e057Binary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/screenshot-grid-fullpage.png differdiff --git a/test/golden-firefox/screenshot-iframe.png b/test/__snapshots__/page-screenshot/firefox/screenshot-iframe.pngsimilarity index 100%rename from test/golden-firefox/screenshot-iframe.pngrename to test/__snapshots__/page-screenshot/firefox/screenshot-iframe.pngdiff --git a/test/__snapshots__/page-screenshot/firefox/screenshot-offscreen-clip.png b/test/__snapshots__/page-screenshot/firefox/screenshot-offscreen-clip.pngnew file mode 100644index 0000000000..cfab2376beBinary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/screenshot-offscreen-clip.png differdiff --git a/test/__snapshots__/page-screenshot/firefox/screenshot-sanity.png b/test/__snapshots__/page-screenshot/firefox/screenshot-sanity.pngnew file mode 100644index 0000000000..7b16493355Binary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/screenshot-sanity.png differdiff --git a/test/__snapshots__/page-screenshot/firefox/screenshot-translateZ.png b/test/__snapshots__/page-screenshot/firefox/screenshot-translateZ.pngnew file mode 100644index 0000000000..7dc10f2f5aBinary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/screenshot-translateZ.png differdiff --git a/test/__snapshots__/page-screenshot/firefox/white.jpg b/test/__snapshots__/page-screenshot/firefox/white.jpgnew file mode 100644index 0000000000..40eb86d77bBinary files /dev/null and b/test/__snapshots__/page-screenshot/firefox/white.jpg differdiff --git a/test/__snapshots__/page-screenshot/webkit/grid-cell-0.png b/test/__snapshots__/page-screenshot/webkit/grid-cell-0.pngnew file mode 100644index 0000000000..117929e479Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/grid-cell-0.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/grid-cell-1.png b/test/__snapshots__/page-screenshot/webkit/grid-cell-1.pngnew file mode 100644index 0000000000..9007ff0a95Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/grid-cell-1.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-canvas.png b/test/__snapshots__/page-screenshot/webkit/screenshot-canvas.pngnew file mode 100644index 0000000000..0a40e94959Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-canvas.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-clip-odd-size.png b/test/__snapshots__/page-screenshot/webkit/screenshot-clip-odd-size.pngnew file mode 100644index 0000000000..86a4d51ca0Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-clip-odd-size.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-clip-rect.png b/test/__snapshots__/page-screenshot/webkit/screenshot-clip-rect.pngnew file mode 100644index 0000000000..8bfbcda983Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-clip-rect.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-device-scale-factor.png b/test/__snapshots__/page-screenshot/webkit/screenshot-device-scale-factor.pngnew file mode 100644index 0000000000..a9729736efBinary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-device-scale-factor.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-grid-fullpage.png b/test/__snapshots__/page-screenshot/webkit/screenshot-grid-fullpage.pngnew file mode 100644index 0000000000..494d216e00Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-grid-fullpage.png differdiff --git a/test/golden-webkit/screenshot-iframe.png b/test/__snapshots__/page-screenshot/webkit/screenshot-iframe.pngsimilarity index 100%rename from test/golden-webkit/screenshot-iframe.pngrename to test/__snapshots__/page-screenshot/webkit/screenshot-iframe.pngdiff --git a/test/golden-webkit/screenshot-mobile-clip.png b/test/__snapshots__/page-screenshot/webkit/screenshot-mobile-clip.pngsimilarity index 100%rename from test/golden-webkit/screenshot-mobile-clip.pngrename to test/__snapshots__/page-screenshot/webkit/screenshot-mobile-clip.pngdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-mobile-fullpage.png b/test/__snapshots__/page-screenshot/webkit/screenshot-mobile-fullpage.pngnew file mode 100644index 0000000000..8e72219561Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-mobile-fullpage.png differdiff --git a/test/golden-chromium/screenshot-mobile.png b/test/__snapshots__/page-screenshot/webkit/screenshot-mobile.pngsimilarity index 100%rename from test/golden-chromium/screenshot-mobile.pngrename to test/__snapshots__/page-screenshot/webkit/screenshot-mobile.pngdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-offscreen-clip.png b/test/__snapshots__/page-screenshot/webkit/screenshot-offscreen-clip.pngnew file mode 100644index 0000000000..9882dd3b49Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-offscreen-clip.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-sanity.png b/test/__snapshots__/page-screenshot/webkit/screenshot-sanity.pngnew file mode 100644index 0000000000..4cf1a338fcBinary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-sanity.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/screenshot-translateZ.png b/test/__snapshots__/page-screenshot/webkit/screenshot-translateZ.pngnew file mode 100644index 0000000000..74a525b9c5Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/screenshot-translateZ.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/transparent.png b/test/__snapshots__/page-screenshot/webkit/transparent.pngnew file mode 100644index 0000000000..2c60e44978Binary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/transparent.png differdiff --git a/test/__snapshots__/page-screenshot/webkit/white.jpg b/test/__snapshots__/page-screenshot/webkit/white.jpgnew file mode 100644index 0000000000..3f6faefd6eBinary files /dev/null and b/test/__snapshots__/page-screenshot/webkit/white.jpg differdiff --git a/test/__snapshots__/request-fulfill/chromium/mock-binary-response.png b/test/__snapshots__/request-fulfill/chromium/mock-binary-response.pngnew file mode 100644index 0000000000..e4f6191796Binary files /dev/null and b/test/__snapshots__/request-fulfill/chromium/mock-binary-response.png differdiff --git a/test/golden-chromium/mock-svg.png b/test/__snapshots__/request-fulfill/chromium/mock-svg.pngsimilarity index 100%rename from test/golden-chromium/mock-svg.pngrename to test/__snapshots__/request-fulfill/chromium/mock-svg.pngdiff --git a/test/golden-firefox/mock-binary-response.png b/test/__snapshots__/request-fulfill/firefox/mock-binary-response.pngsimilarity index 100%rename from test/golden-firefox/mock-binary-response.pngrename to test/__snapshots__/request-fulfill/firefox/mock-binary-response.pngdiff --git a/test/golden-firefox/mock-svg.png b/test/__snapshots__/request-fulfill/firefox/mock-svg.pngsimilarity index 100%rename from test/golden-firefox/mock-svg.pngrename to test/__snapshots__/request-fulfill/firefox/mock-svg.pngdiff --git a/test/__snapshots__/request-fulfill/webkit/mock-binary-response.png b/test/__snapshots__/request-fulfill/webkit/mock-binary-response.pngnew file mode 100644index 0000000000..c7598e390eBinary files /dev/null and b/test/__snapshots__/request-fulfill/webkit/mock-binary-response.png differdiff --git a/test/golden-webkit/mock-svg.png b/test/__snapshots__/request-fulfill/webkit/mock-svg.pngsimilarity index 100%rename from test/golden-webkit/mock-svg.pngrename to test/__snapshots__/request-fulfill/webkit/mock-svg.pngdiff --git a/test/base.fixture.ts b/test/base.fixture.tsindex c781ea5b04..ed1e75f9bb 100644--- a/test/base.fixture.ts+++ b/test/base.fixture.ts@@ -26,6 +26,7 @@ import { setUnderTest } from '../lib/helper';import { installCoverageHooks } from './runner/coverage';import { valueFromEnv } from './runner/utils';import { registerFixture, registerWorkerFixture} from './runner/fixtures';+import './runner/builtin.fixtures';import {mkdtempAsync, removeFolderAsync} from './utils';@@ -37,13 +38,11 @@ const platform = os.platform();declare global {interface WorkerState {asset: (path: string) => string;- parallelIndex: number;defaultBrowserOptions: LaunchOptions;golden: (path: string) => string;playwright: typeof import('../index');browserType: BrowserType<Browser>;browser: Browser;- tmpDir: string;}interface FixtureState {toImpl: (rpcObject: any) => any;@@ -62,10 +61,6 @@ declare global {(global as any).FFOX = browserName === 'firefox';(global as any).WEBKIT = browserName === 'webkit';-registerWorkerFixture('parallelIndex', async ({}, test) => {- await test(parseInt(process.env.JEST_WORKER_ID, 10) - 1);-});-registerWorkerFixture('httpService', async ({parallelIndex}, test) => {const assetsPath = path.join(__dirname, 'assets');const cachedPath = path.join(__dirname, 'assets', 'cached');@@ -139,7 +134,7 @@ registerWorkerFixture('playwright', async({parallelIndex}, test) => {async function teardownCoverage() {uninstall();- const coveragePath = path.join(path.join(__dirname, 'output-' + browserName), 'coverage', parallelIndex + '.json');+ const coveragePath = path.join(path.join(__dirname, 'coverage-report'), 'coverage', parallelIndex + '.json');const coverageJSON = [...coverage.keys()].filter(key => coverage.get(key));await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');@@ -205,5 +200,5 @@ registerWorkerFixture('asset', async ({}, test) => {});registerWorkerFixture('golden', async ({browserName}, test) => {- await test(p => path.join(__dirname, `golden-${browserName}`, p));+ await test(p => path.join(`${browserName}`, p));});diff --git a/test/chromium/oopif.spec.ts b/test/chromium/oopif.spec.tsindex d275b0c7b8..00ec54ac9c 100644--- a/test/chromium/oopif.spec.ts+++ b/test/chromium/oopif.spec.ts@@ -155,7 +155,7 @@ it.skip(!CHROMIUM)('should take screenshot', async({browser, page, server, goldeawait page.goto(server.PREFIX + '/dynamic-oopif.html');expect(page.frames().length).toBe(2);expect(await countOOPIFs(browser)).toBe(1);- expect(await page.screenshot()).toMatchImage(golden('screenshot-oopif.png'));+ expect(await page.screenshot()).toMatchImage(golden('screenshot-oopif.png'), { threshold: 0.3 });});it.skip(!CHROMIUM)('should load oopif iframes with subresources and request interception', async function({browser, page, server, context}) {diff --git a/test/chromium/tracing.spec.ts b/test/chromium/tracing.spec.tsindex b58701f130..2b8940521f 100644--- a/test/chromium/tracing.spec.ts+++ b/test/chromium/tracing.spec.ts@@ -13,6 +13,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import '../runner/builtin.fixtures';import '../base.fixture';import { registerFixture } from '../runner/fixtures';diff --git a/test/defaultbrowsercontext.spec.ts b/test/defaultbrowsercontext.spec.tsindex 3ab31c5d90..b49acf26f9 100644--- a/test/defaultbrowsercontext.spec.ts+++ b/test/defaultbrowsercontext.spec.ts@@ -14,6 +14,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import './runner/builtin.fixtures';import './base.fixture';import { registerFixture } from './runner/fixtures';import fs from 'fs';diff --git a/test/download.spec.ts b/test/download.spec.tsindex 006692b099..c3c048c9a7 100644--- a/test/download.spec.ts+++ b/test/download.spec.ts@@ -13,6 +13,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import './runner/builtin.fixtures';import './base.fixture';import fs from 'fs';diff --git a/test/downloads-path.spec.ts b/test/downloads-path.spec.tsindex 2acfbae624..73031f8a70 100644--- a/test/downloads-path.spec.ts+++ b/test/downloads-path.spec.ts@@ -13,7 +13,11 @@* See the License for the specific language governing permissions and* limitations under the License.*/+++import './runner/builtin.fixtures';import './base.fixture';+import { registerFixture } from './runner/fixtures';import path from 'path';diff --git a/test/golden-chromium/csscoverage-involved.txt b/test/golden-chromium/csscoverage-involved.txtdeleted file mode 100644index 9b851d0bd3..0000000000--- a/test/golden-chromium/csscoverage-involved.txt+++ /dev/null@@ -1,16 +0,0 @@-[- {- "url": "http://localhost:<PORT>/csscoverage/involved.html",- "ranges": [- {- "start": 149,- "end": 297- },- {- "start": 327,- "end": 433- }- ],- "text": "\n@charset \"utf-8\";\n@namespace svg url(http://www.w3.org/2000/svg);\n@font-face {\n font-family: \"Example Font\";\n src: url(\"./Dosis-Regular.ttf\");\n}\n\n#fluffy {\n border: 1px solid black;\n z-index: 1;\n /* -webkit-disabled-property: rgb(1, 2, 3) */\n -lol-cats: \"dogs\" /* non-existing property */\n}\n\n@media (min-width: 1px) {\n span {\n -webkit-border-radius: 10px;\n font-family: \"Example Font\";\n animation: 1s identifier;\n }\n}\n"- }-]\ No newline at end of filediff --git a/test/golden-chromium/grid-cell-0.png b/test/golden-chromium/grid-cell-0.pngdeleted file mode 100644index ff282e989b..0000000000Binary files a/test/golden-chromium/grid-cell-0.png and /dev/null differdiff --git a/test/golden-chromium/grid-cell-2.png b/test/golden-chromium/grid-cell-2.pngdeleted file mode 100644index 7b01753b6a..0000000000Binary files a/test/golden-chromium/grid-cell-2.png and /dev/null differdiff --git a/test/golden-chromium/grid-cell-3.png b/test/golden-chromium/grid-cell-3.pngdeleted file mode 100644index b9b8b2922b..0000000000Binary files a/test/golden-chromium/grid-cell-3.png and /dev/null differdiff --git a/test/golden-chromium/jscoverage-involved.txt b/test/golden-chromium/jscoverage-involved.txtdeleted file mode 100644index 6f28e1580e..0000000000--- a/test/golden-chromium/jscoverage-involved.txt+++ /dev/null@@ -1,28 +0,0 @@-[- {- "url": "http://localhost:<PORT>/jscoverage/involved.html",- "ranges": [- {- "start": 0,- "end": 35- },- {- "start": 50,- "end": 100- },- {- "start": 107,- "end": 141- },- {- "start": 148,- "end": 160- },- {- "start": 168,- "end": 207- }- ],- "text": "\nfunction foo() {\n if (1 > 2)\n console.log(1);\n if (1 < 2)\n console.log(2);\n let x = 1 > 2 ? 'foo' : 'bar';\n let y = 1 < 2 ? 'foo' : 'bar';\n let z = () => {};\n let q = () => {};\n q();\n}\n\nfoo();\n"- }-]\ No newline at end of filediff --git a/test/golden-chromium/mock-binary-response.png b/test/golden-chromium/mock-binary-response.pngdeleted file mode 100644index 8595e0598e..0000000000Binary files a/test/golden-chromium/mock-binary-response.png and /dev/null differdiff --git a/test/golden-chromium/screenshot-element-fractional.png b/test/golden-chromium/screenshot-element-fractional.pngdeleted file mode 100644index 35c53377f9..0000000000Binary files a/test/golden-chromium/screenshot-element-fractional.png and /dev/null differdiff --git a/test/golden-chromium/screenshot-oopif.png b/test/golden-chromium/screenshot-oopif.pngdeleted file mode 100644index 56aa8706bb..0000000000Binary files a/test/golden-chromium/screenshot-oopif.png and /dev/null differdiff --git a/test/golden-chromium/white.jpg b/test/golden-chromium/white.jpgdeleted file mode 100644index fb9070def3..0000000000Binary files a/test/golden-chromium/white.jpg and /dev/null differdiff --git a/test/golden-firefox/grid-cell-0.png b/test/golden-firefox/grid-cell-0.pngdeleted file mode 100644index 4677bdbc4f..0000000000Binary files a/test/golden-firefox/grid-cell-0.png and /dev/null differdiff --git a/test/golden-firefox/grid-cell-1.png b/test/golden-firefox/grid-cell-1.pngdeleted file mode 100644index 532dc8db65..0000000000Binary files a/test/golden-firefox/grid-cell-1.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-clip-odd-size.png b/test/golden-firefox/screenshot-clip-odd-size.pngdeleted file mode 100644index b010d1f87f..0000000000Binary files a/test/golden-firefox/screenshot-clip-odd-size.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-clip-rect.png b/test/golden-firefox/screenshot-clip-rect.pngdeleted file mode 100644index ac23b7de50..0000000000Binary files a/test/golden-firefox/screenshot-clip-rect.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-element-bounding-box.png b/test/golden-firefox/screenshot-element-bounding-box.pngdeleted file mode 100644index 32e05bf05b..0000000000Binary files a/test/golden-firefox/screenshot-element-bounding-box.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-element-fractional.png b/test/golden-firefox/screenshot-element-fractional.pngdeleted file mode 100644index 35c53377f9..0000000000Binary files a/test/golden-firefox/screenshot-element-fractional.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-element-larger-than-viewport.png b/test/golden-firefox/screenshot-element-larger-than-viewport.pngdeleted file mode 100644index 5fcdb92355..0000000000Binary files a/test/golden-firefox/screenshot-element-larger-than-viewport.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-element-padding-border.png b/test/golden-firefox/screenshot-element-padding-border.pngdeleted file mode 100644index 917dd48188..0000000000Binary files a/test/golden-firefox/screenshot-element-padding-border.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-element-scrolled-into-view.png b/test/golden-firefox/screenshot-element-scrolled-into-view.pngdeleted file mode 100644index 917dd48188..0000000000Binary files a/test/golden-firefox/screenshot-element-scrolled-into-view.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-grid-fullpage.png b/test/golden-firefox/screenshot-grid-fullpage.pngdeleted file mode 100644index d6d38217f7..0000000000Binary files a/test/golden-firefox/screenshot-grid-fullpage.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-mobile.png b/test/golden-firefox/screenshot-mobile.pngdeleted file mode 100644index 4ba38135af..0000000000Binary files a/test/golden-firefox/screenshot-mobile.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-offscreen-clip.png b/test/golden-firefox/screenshot-offscreen-clip.pngdeleted file mode 100644index 21f7b0f461..0000000000Binary files a/test/golden-firefox/screenshot-offscreen-clip.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-sanity.png b/test/golden-firefox/screenshot-sanity.pngdeleted file mode 100644index ecab61fe17..0000000000Binary files a/test/golden-firefox/screenshot-sanity.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-translateZ.png b/test/golden-firefox/screenshot-translateZ.pngdeleted file mode 100644index e3f5642e60..0000000000Binary files a/test/golden-firefox/screenshot-translateZ.png and /dev/null differdiff --git a/test/golden-firefox/screenshot-webgl.png b/test/golden-firefox/screenshot-webgl.pngdeleted file mode 100644index 76109512b5..0000000000Binary files a/test/golden-firefox/screenshot-webgl.png and /dev/null differdiff --git a/test/golden-firefox/white.jpg b/test/golden-firefox/white.jpgdeleted file mode 100644index fb9070def3..0000000000Binary files a/test/golden-firefox/white.jpg and /dev/null differdiff --git a/test/golden-webkit/grid-cell-0.png b/test/golden-webkit/grid-cell-0.pngdeleted file mode 100644index 5ae546557b..0000000000Binary files a/test/golden-webkit/grid-cell-0.png and /dev/null differdiff --git a/test/golden-webkit/grid-cell-1.png b/test/golden-webkit/grid-cell-1.pngdeleted file mode 100644index 1110528326..0000000000Binary files a/test/golden-webkit/grid-cell-1.png and /dev/null differdiff --git a/test/golden-webkit/mock-binary-response.png b/test/golden-webkit/mock-binary-response.pngdeleted file mode 100644index 8595e0598e..0000000000Binary files a/test/golden-webkit/mock-binary-response.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-canvas.png b/test/golden-webkit/screenshot-canvas.pngdeleted file mode 100644index dfafbda638..0000000000Binary files a/test/golden-webkit/screenshot-canvas.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-clip-odd-size.png b/test/golden-webkit/screenshot-clip-odd-size.pngdeleted file mode 100644index b010d1f87f..0000000000Binary files a/test/golden-webkit/screenshot-clip-odd-size.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-clip-rect.png b/test/golden-webkit/screenshot-clip-rect.pngdeleted file mode 100644index ac23b7de50..0000000000Binary files a/test/golden-webkit/screenshot-clip-rect.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-device-scale-factor.png b/test/golden-webkit/screenshot-device-scale-factor.pngdeleted file mode 100644index e02fdc8946..0000000000Binary files a/test/golden-webkit/screenshot-device-scale-factor.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-bounding-box.png b/test/golden-webkit/screenshot-element-bounding-box.pngdeleted file mode 100644index 32e05bf05b..0000000000Binary files a/test/golden-webkit/screenshot-element-bounding-box.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-fractional-offset.png b/test/golden-webkit/screenshot-element-fractional-offset.pngdeleted file mode 100644index 6b65c6fd6b..0000000000Binary files a/test/golden-webkit/screenshot-element-fractional-offset.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-fractional.png b/test/golden-webkit/screenshot-element-fractional.pngdeleted file mode 100644index 35c53377f9..0000000000Binary files a/test/golden-webkit/screenshot-element-fractional.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-mobile.png b/test/golden-webkit/screenshot-element-mobile.pngdeleted file mode 100644index c2c3ddca29..0000000000Binary files a/test/golden-webkit/screenshot-element-mobile.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-padding-border.png b/test/golden-webkit/screenshot-element-padding-border.pngdeleted file mode 100644index 917dd48188..0000000000Binary files a/test/golden-webkit/screenshot-element-padding-border.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-rotate.png b/test/golden-webkit/screenshot-element-rotate.pngdeleted file mode 100644index b6eadf8907..0000000000Binary files a/test/golden-webkit/screenshot-element-rotate.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-element-scrolled-into-view.png b/test/golden-webkit/screenshot-element-scrolled-into-view.pngdeleted file mode 100644index 917dd48188..0000000000Binary files a/test/golden-webkit/screenshot-element-scrolled-into-view.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-grid-fullpage.png b/test/golden-webkit/screenshot-grid-fullpage.pngdeleted file mode 100644index d6d38217f7..0000000000Binary files a/test/golden-webkit/screenshot-grid-fullpage.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-mobile-fullpage.png b/test/golden-webkit/screenshot-mobile-fullpage.pngdeleted file mode 100644index bb975e20ef..0000000000Binary files a/test/golden-webkit/screenshot-mobile-fullpage.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-mobile.png b/test/golden-webkit/screenshot-mobile.pngdeleted file mode 100644index 4ba38135af..0000000000Binary files a/test/golden-webkit/screenshot-mobile.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-offscreen-clip.png b/test/golden-webkit/screenshot-offscreen-clip.pngdeleted file mode 100644index 21f7b0f461..0000000000Binary files a/test/golden-webkit/screenshot-offscreen-clip.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-sanity.png b/test/golden-webkit/screenshot-sanity.pngdeleted file mode 100644index ecab61fe17..0000000000Binary files a/test/golden-webkit/screenshot-sanity.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-translateZ.png b/test/golden-webkit/screenshot-translateZ.pngdeleted file mode 100644index e3f5642e60..0000000000Binary files a/test/golden-webkit/screenshot-translateZ.png and /dev/null differdiff --git a/test/golden-webkit/screenshot-webgl.png b/test/golden-webkit/screenshot-webgl.pngdeleted file mode 100644index 76109512b5..0000000000Binary files a/test/golden-webkit/screenshot-webgl.png and /dev/null differdiff --git a/test/golden-webkit/transparent.png b/test/golden-webkit/transparent.pngdeleted file mode 100644index 6c1fe85b52..0000000000Binary files a/test/golden-webkit/transparent.png and /dev/null differdiff --git a/test/golden-webkit/white.jpg b/test/golden-webkit/white.jpgdeleted file mode 100644index fb9070def3..0000000000Binary files a/test/golden-webkit/white.jpg and /dev/null differdiff --git a/test/golden-webkit/white.png b/test/golden-webkit/white.pngdeleted file mode 100644index e2c01a35a7..0000000000Binary files a/test/golden-webkit/white.png and /dev/null differdiff --git a/test/headful.spec.ts b/test/headful.spec.tsindex 8b860af45d..169fbe0feb 100644--- a/test/headful.spec.ts+++ b/test/headful.spec.ts@@ -13,6 +13,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import './runner/builtin.fixtures';import './base.fixture';import utils from './utils';diff --git a/test/page-screenshot.spec.ts b/test/page-screenshot.spec.tsindex 750c148be4..9660d57cc4 100644--- a/test/page-screenshot.spec.ts+++ b/test/page-screenshot.spec.ts@@ -202,7 +202,7 @@ it.skip(ffheadful)('should work for canvas', async({page, server, golden}) => {await page.setViewportSize({width: 500, height: 500});await page.goto(server.PREFIX + '/screenshots/canvas.html');const screenshot = await page.screenshot();- expect(screenshot).toMatchImage(golden('screenshot-canvas.png'));+ expect(screenshot).toMatchImage(golden('screenshot-canvas.png'), { threshold: 0.3 });});it.skip(ffheadful)('should work for translateZ', async({page, server, golden}) => {diff --git a/test/pdf.spec.ts b/test/pdf.spec.tsindex 47dfca136c..c3d1f4cf8a 100644--- a/test/pdf.spec.ts+++ b/test/pdf.spec.ts@@ -13,6 +13,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import './runner/builtin.fixtures';import './base.fixture';import fs from 'fs'diff --git a/test/proxy.spec.ts b/test/proxy.spec.tsindex e4999be8ff..65f393c1ff 100644--- a/test/proxy.spec.ts+++ b/test/proxy.spec.ts@@ -13,6 +13,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import './runner/builtin.fixtures';import './base.fixture';import socks from 'socksv5';diff --git a/test/runner/GoldenUtils.js b/test/runner/GoldenUtils.jsindex ff73e2bc4c..837150aa8b 100644--- a/test/runner/GoldenUtils.js+++ b/test/runner/GoldenUtils.js@@ -44,7 +44,7 @@ const GoldenComparators = {* @param {!string} mimeType* @return {?{diff: (!Object:undefined), errorMessage: (string|undefined)}}*/-function compareImages(actualBuffer, expectedBuffer, mimeType) {+function compareImages(actualBuffer, expectedBuffer, mimeType, config = {}) {if (!actualBuffer || !(actualBuffer instanceof Buffer))return { errorMessage: 'Actual result should be Buffer.' };@@ -56,7 +56,7 @@ function compareImages(actualBuffer, expectedBuffer, mimeType) {};}const diff = new PNG({width: expected.width, height: expected.height});- const count = pixelmatch(expected.data, actual.data, diff.data, expected.width, expected.height, {threshold: 0.2});+ const count = pixelmatch(expected.data, actual.data, diff.data, expected.width, expected.height, {threshold: 0.2, ...config});return count > 0 ? { diff: PNG.sync.write(diff) } : null;}@@ -88,8 +88,16 @@ function compareText(actual, expectedBuffer) {* @param {string} path* @return {!{pass: boolean, message: (undefined|string)}}*/-function compare(actual, expectedPath) {+function compare(actual, name, options) {+ const { relativeTestFile, snapshotDir, outputDir, updateSnapshots } = options;+ let expectedPath;+ const testAssetsDir = relativeTestFile.replace(/\.spec\.[jt]s/, '');+ if (path.isAbsolute(name))+ expectedPath = name;+ else+ expectedPath = path.join(snapshotDir, testAssetsDir, name);if (!fs.existsSync(expectedPath)) {+ fs.mkdirSync(path.dirname(expectedPath), { recursive: true });fs.writeFileSync(expectedPath, actual);return {pass: false,@@ -107,15 +115,35 @@ function compare(actual, expectedPath) {};}- const result = comparator(actual, expected, mimeType);+ const result = comparator(actual, expected, mimeType, options.config);if (!result)return { pass: true };- const actualPath = addSuffix(expectedPath, '-actual');- const diffPath = addSuffix(expectedPath, '-diff', result.diffExtension);+ if (updateSnapshots) {+ fs.mkdirSync(path.dirname(expectedPath), { recursive: true });+ fs.writeFileSync(expectedPath, actual);+ return {+ pass: true,+ message: expectedPath + ' running with --update-snapshots, writing actual.'+ };+ }++ let actualPath;+ let diffPath;+ if (path.isAbsolute(name)) {+ actualPath = addSuffix(expectedPath, '-actual');+ diffPath = addSuffix(expectedPath, '-diff', result.diffExtension);+ } else {+ const outputPath = path.join(outputDir, testAssetsDir, name);+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });+ const expectedPathOut = addSuffix(outputPath, '-expected');+ actualPath = addSuffix(outputPath, '-actual');+ diffPath = addSuffix(outputPath, '-diff', result.diffExtension);+ fs.writeFileSync(expectedPathOut, expected);+ }fs.writeFileSync(actualPath, actual);if (result.diff)- fs.writeFileSync(diffPath, result.diff);+ fs.writeFileSync(diffPath, result.diff);const output = [c.red(`Image comparison failed:`),diff --git a/test/runner/builtin.fixtures.js b/test/runner/builtin.fixtures.jsnew file mode 100644index 0000000000..93d5d13415--- /dev/null+++ b/test/runner/builtin.fixtures.js@@ -0,0 +1,48 @@+/**+ * Copyright Microsoft Corporation. All rights reserved.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const fs = require('fs');+const os = require('os');+const path = require('path');+const util = require('util');+const { mkdtempAsync, removeFolderAsync } = require('../utils');+const { registerFixture, registerWorkerFixture } = require('./fixtures');+const mkdirAsync = util.promisify(fs.mkdir.bind(fs));++let workerId;+let outputDir;++registerWorkerFixture('parallelIndex', async ({}, test) => {+ await test(workerId);+});++registerFixture('tmpDir', async ({}, test) => {+ const tmpDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-'));+ await test(tmpDir);+ await removeFolderAsync(tmpDir).catch(e => {});+});++registerWorkerFixture('outputDir', async ({}, test) => {+ await mkdirAsync(outputDir, { recursive: true });+ await test(outputDir);+});++function initializeWorker(options) {+ workerId = options.workerId;+ outputDir = options.outputDir;+}++module.exports = { initializeWorker };diff --git a/test/runner/checkCoverage.js b/test/runner/checkCoverage.jsindex 6cda377299..8db519b333 100644--- a/test/runner/checkCoverage.js+++ b/test/runner/checkCoverage.js@@ -38,7 +38,7 @@ if (browserName !== 'chromium') {if (browserName === 'webkit')api.delete('browserContext.clearPermissions');-const coverageDir = path.join(__dirname, '..', 'output-' + browserName, 'coverage');+const coverageDir = path.join(__dirname, '..', 'coverage-report', 'coverage');const coveredMethods = new Set();for (const file of getCoverageFiles(coverageDir)) {diff --git a/test/runner/fixturesUI.js b/test/runner/fixturesUI.jsindex 643567449c..235e1b7027 100644--- a/test/runner/fixturesUI.js+++ b/test/runner/fixturesUI.js@@ -23,7 +23,6 @@ Error.stackTraceLimit = 15;global.testOptions = require('./testOptions');global.registerFixture = registerFixture;global.registerWorkerFixture = registerWorkerFixture;-process.env.JEST_WORKER_ID = 1;const fixturePool = new FixturePool();let revertBabelRequire;diff --git a/test/runner/index.js b/test/runner/index.jsindex 02e68c9e42..e09ee6ab87 100644--- a/test/runner/index.js+++ b/test/runner/index.js@@ -31,10 +31,13 @@ program.option('--trial-run', 'Only collect the matching tests and report them as passing').option('--quiet', 'Suppress stdio', false).option('--debug', 'Run tests in-process for debugging', false)+ .option('--output <outputDir>', 'Folder for output artifacts, default: test-results', path.join(process.cwd(), 'test-results')).option('--timeout <timeout>', 'Specify test timeout threshold (in milliseconds), default: 10000', 10000)+ .option('-u, --update-snapshots', 'Use this flag to re-record every snapshot that fails during this test run').action(async (command) => {- // Collect files- const files = collectFiles(path.join(process.cwd(), command.args[0]), command.args.slice(1));+ // Collect files]+ const testDir = path.join(process.cwd(), command.args[0]);+ const files = collectFiles(testDir, '', command.args.slice(1));const rootSuite = new createTestSuite();let total = 0;@@ -44,6 +47,7 @@ programforbidOnly: command.forbidOnly || undefined,grep: command.grep,reporter: NullReporter,+ testDir,timeout: command.timeout,trialRun: true,});@@ -74,10 +78,14 @@ programquiet: command.quiet,grep: command.grep,jobs,+ outputDir: command.output,reporter: command.reporter,retries: command.retries,+ snapshotDir: path.join(testDir, '__snapshots__'),+ testDir,timeout: command.timeout,trialRun: command.trialRun,+ updateSnapshots: command.updateSnapshots});await runner.run(files);await runner.stop();@@ -86,24 +94,26 @@ programprogram.parse(process.argv);-function collectFiles(dir, filters) {- if (fs.statSync(dir).isFile())- return [dir];+function collectFiles(testDir, dir, filters) {+ const fullDir = path.join(testDir, dir);+ if (fs.statSync(fullDir).isFile())+ return [fullDir];const files = [];- for (const name of fs.readdirSync(dir)) {- if (fs.lstatSync(path.join(dir, name)).isDirectory()) {- files.push(...collectFiles(path.join(dir, name), filters));+ for (const name of fs.readdirSync(fullDir)) {+ if (fs.lstatSync(path.join(fullDir, name)).isDirectory()) {+ files.push(...collectFiles(testDir, path.join(dir, name), filters));continue;}if (!name.endsWith('spec.ts'))continue;+ const relativeName = path.join(dir, name);+ const fullName = path.join(testDir, relativeName);if (!filters.length) {- files.push(path.join(dir, name));+ files.push(fullName);continue;}- const fullName = path.join(dir, name);for (const filter of filters) {- if (fullName.includes(filter)) {+ if (relativeName.includes(filter)) {files.push(fullName);break;}diff --git a/test/runner/runner.js b/test/runner/runner.jsindex e0741f56ba..ea9b9ac741 100644--- a/test/runner/runner.js+++ b/test/runner/runner.js@@ -20,7 +20,7 @@ const { EventEmitter } = require('events');const Mocha = require('mocha');const builtinReporters = require('mocha/lib/reporters');const DotRunner = require('./dotReporter');-const { computeWorkerHash, FixturePool } = require('./fixtures');+const { computeWorkerHash } = require('./fixtures');const constants = Mocha.Runner.constants;// Mocha runner does not remove uncaughtException listeners.@@ -225,7 +225,7 @@ class OopWorker extends EventEmitter {}async init() {- this.process.send({ method: 'init', params: { workerId: lastWorkerId++ } });+ this.process.send({ method: 'init', params: { workerId: lastWorkerId++, ...this.runner._options } });await new Promise(f => this.process.once('message', f)); // Ready ack}@@ -259,6 +259,10 @@ class InProcessWorker extends EventEmitter {}async init() {+ const { initializeImageMatcher } = require('./testRunner');+ const { initializeWorker } = require('./builtin.fixtures');+ initializeImageMatcher(this.runner._options);+ initializeWorker({ ...this.runner._options.outputDir, workerId: 0 });}async run(entry) {diff --git a/test/runner/testRunner.js b/test/runner/testRunner.jsindex ca46de001f..b64aeb1e7b 100644--- a/test/runner/testRunner.js+++ b/test/runner/testRunner.js@@ -14,6 +14,7 @@* limitations under the License.*/+const path = require('path');const Mocha = require('mocha');const { fixturesUI } = require('./fixturesUI');const { EventEmitter } = require('events');@@ -22,14 +23,6 @@ global.expect = require('expect');global.testOptions = require('./testOptions');const GoldenUtils = require('./GoldenUtils');-(function extendExpects() {- function toMatchImage(received, path) {- const {pass, message} = GoldenUtils.compare(received, path);- return {pass, message: () => message};- };- global.expect.extend({ toMatchImage });-})();-class NullReporter {}class TestRunner extends EventEmitter {@@ -50,7 +43,7 @@ class TestRunner extends EventEmitter {this._passes = 0;this._failures = 0;this._pending = 0;-+ this._relativeTestFile = path.relative(options.testDir, file);this.mocha.addFile(file);this.mocha.suite.filterOnly();this.mocha.loadFiles();@@ -65,6 +58,7 @@ class TestRunner extends EventEmitter {const constants = Mocha.Runner.constants;runner.on(constants.EVENT_TEST_BEGIN, test => {+ relativeTestFile = this._relativeTestFile;if (this._failedWithError) {++remaining;return;@@ -185,4 +179,14 @@ function serializeError(error) {return trimCycles(error);}-module.exports = { TestRunner, createTestSuite };+let relativeTestFile;++function initializeImageMatcher(options) {+ function toMatchImage(received, name, config) {+ const { pass, message } = GoldenUtils.compare(received, name, { ...options, relativeTestFile, config });+ return { pass, message: () => message };+ };+ global.expect.extend({ toMatchImage });+}++module.exports = { TestRunner, createTestSuite, initializeImageMatcher };diff --git a/test/runner/worker.js b/test/runner/worker.jsindex 41eb00cb3a..001ce4cfa9 100644--- a/test/runner/worker.js+++ b/test/runner/worker.js@@ -17,7 +17,9 @@const debug = require('debug');const { fixturePool } = require('./fixturesUI');const { gracefullyCloseAll } = require('../../lib/server/processLauncher');-const { TestRunner } = require('./testRunner');+const { TestRunner, initializeImageMatcher } = require('./testRunner');+const { initializeWorker } = require('./builtin.fixtures');+const util = require('util');let closed = false;@@ -49,12 +51,17 @@ process.on('SIGINT',() => {});process.on('SIGTERM',() => {});process.on('message', async message => {- if (message.method === 'init')- process.env.JEST_WORKER_ID = message.params.workerId;+ if (message.method === 'init') {+ initializeWorker(message.params);+ initializeImageMatcher(message.params);+ return;+ }if (message.method === 'stop') {await fixturePool.teardownScope('worker');await gracefullyCloseAndExit();- } if (message.method === 'run') {+ return;+ }+ if (message.method === 'run') {const testRunner = new TestRunner(message.params.file, message.params.startOrdinal, message.params.options);for (const event of ['test', 'pending', 'pass', 'fail', 'done'])testRunner.on(event, sendMessageToParent.bind(null, event));diff --git a/test/screencast.spec.ts b/test/screencast.spec.tsindex 6bffb979cb..330bb3add5 100644--- a/test/screencast.spec.ts+++ b/test/screencast.spec.ts@@ -13,6 +13,8 @@* See the License for the specific language governing permissions and* limitations under the License.*/++import './runner/builtin.fixtures';import './base.fixture';import { registerFixture } from './runner/fixtures';import { Page } from '..';diff --git a/test/types.d.ts b/test/types.d.tsindex 0398334ba2..d51fcec8e3 100644--- a/test/types.d.ts+++ b/test/types.d.ts@@ -1,3 +1,19 @@+/**+ * Copyright Microsoft Corporation. All rights reserved.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+type ServerResponse = import('http').ServerResponse;type IncomingMessage = import('http').IncomingMessage;@@ -11,6 +27,8 @@ type ItFunction<STATE> = ((name: string, inner: (state: STATE) => Promise<void>)};interface WorkerState {+ parallelIndex: number;+ tmpDir: string;}interface FixtureState {@@ -19,7 +37,7 @@ interface FixtureState {declare module '' {module 'expect/build/types' {interface Matchers<R> {- toMatchImage(path: string): R;+ toMatchImage(path: string, options?: { threshold?: number }): R;}}}