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(firefox): make headful screencast tests work under xvfb (#3421)
Yury Semikhatskyf0fcdc8f51dc
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 16bdb483a6..c55aac3858 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -38,7 +38,7 @@ jobs:# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR# Wrap `npm run` in a subshell to redirect STDERR to file.# Enable core dumps in the subshell.- - run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000 && npm run coverage"+ - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000 && npm run coverage"env:BROWSER: ${{ matrix.browser }}DEBUG: "pw:*,-pw:wrapped*,-pw:test*"@@ -160,7 +160,7 @@ jobs:# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR# Wrap `npm run` in a subshell to redirect STDERR to file.# Enable core dumps in the subshell.- - run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000"+ - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000"if: ${{ always() }}env:BROWSER: ${{ matrix.browser }}@@ -194,7 +194,7 @@ jobs:# XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR# Wrap `npm run` in a subshell to redirect STDERR to file.# Enable core dumps in the subshell.- - run: xvfb-run --auto-servernum -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000"+ - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test/runner --jobs=1 --forbid-only --timeout=30000"env:BROWSER: ${{ matrix.browser }}DEBUG: "pw:*,-pw:wrapped*,-pw:test*"diff --git a/test/screencast.spec.ts b/test/screencast.spec.tsindex 04170ce130..f93bc143c3 100644--- a/test/screencast.spec.ts+++ b/test/screencast.spec.ts@@ -148,6 +148,17 @@ class VideoPlayer {}, timestamp);}+ async seekFirstNonEmptyFrame() {+ let time = 0;+ for (let i = 0; i < 10; i++) {+ await this.seek(time);+ const pixels = await this.pixels();+ if (!pixels.every(p => p === 255))+ return;+ time += 0.1;+ }+ }+async seekLastNonEmptyFrame() {const duration = await this.duration();let time = duration - 0.01;@@ -176,8 +187,7 @@ class VideoPlayer {}}-// TODO: the test fails in headful Firefox when running under xvfb.-it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture static page', async({page, persistentDirectory, videoPlayer, toImpl}) => {+it.fail(CHROMIUM)('should capture static page', async({page, persistentDirectory, videoPlayer, toImpl}) => {if (!toImpl)return;const videoFile = path.join(persistentDirectory, 'v.webm');@@ -204,7 +214,7 @@ it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture static page', async({pa});// TODO: the test fails in headful Firefox when running under xvfb.-it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture navigation', async({page, persistentDirectory, server, videoPlayer, toImpl}) => {+it.fail(CHROMIUM)('should capture navigation', async({page, persistentDirectory, server, videoPlayer, toImpl}) => {if (!toImpl)return;const videoFile = path.join(persistentDirectory, 'v.webm');@@ -225,7 +235,7 @@ it.fail(CHROMIUM || (FFOX && !HEADLESS))('should capture navigation', async({pagexpect(duration).toBeGreaterThan(0);{- await videoPlayer.seek(0);+ await videoPlayer.seekFirstNonEmptyFrame();const pixels = await videoPlayer.pixels();expectAll(pixels, almostBlack);}