Conditionally wrap pest with xvfb-run when available#855
Draft
JoshSalway wants to merge 3 commits intolaravel:1.xfrom
Draft
Conditionally wrap pest with xvfb-run when available#855JoshSalway wants to merge 3 commits intolaravel:1.xfrom
JoshSalway wants to merge 3 commits intolaravel:1.xfrom
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
Pest v4 browser tests in headed mode (e.g. using debug()) fail with "Looks like you launched a headed browser without having a XServer running" because the Sail container has no display server. Wrap the pest command with xvfb-run to provide a virtual framebuffer. This is transparent for non-browser tests and enables headed Playwright browser tests to work inside the container. Fixes laravel#815 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only wrap pest with xvfb-run when it is actually installed in the container. Stock Sail containers without Playwright do not have xvfb-run, so unconditionally using it breaks sail pest for users who have not run npx playwright install-deps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #815 - Pest v4 browser tests fail in headed mode inside Sail containers with "XServer not running" error because the
pestcommand lacks a virtual display server.This PR wraps the
pestcommand withxvfb-runonly whenxvfb-runis available in the container. Stock Sail containers that have not runnpx playwright install-depsdo not havexvfb-runinstalled, so unconditionally wrapping the command would breaksail pestfor those users.Steps to Reproduce
pest-plugin-browser$page = visit('/')->debug())sail pest tests/BrowserBefore (Bug)
PR #812 added Playwright support to Sail (including
npx playwright install-depswhich installsxvfb), but thesail pestcommand runs Pest directly without wrapping it in a virtual display. Headed Playwright tests require an X display server.After (Fix)
Browser tests run successfully inside the container.
xvfb-runprovides a virtual framebuffer that enables headed Playwright tests to work transparently. Non-browser Pest tests are unaffected (xvfb-runis transparent for tests that do not use a display).The Fix
Conditionally wraps the pest command with
xvfb-runonly when it is available in the container:This ensures:
xvfb-runwrapper for headed browser testsBreaking Changes
None. The check is backward-compatible with all Sail containers.
Files Changed
bin/sail- Conditionally wrap pest command withxvfb-runwhen available