Pest v4 browser tests fail in headed mode on Sail (WSL): XServer not running
Sail Version
1.45
Laravel Version
12.28.1
PHP Version
8.4
Operating System
Windows (WSL)
OS Version
Ubuntu 22.04.4 LTS
Description
I tried running the new Pest v4 browser tests on the latest Sail release v1.45.0, which added support for Pest v4 browser tests (PR #812).
When running in headless mode, everything works fine. But when attempting to run in headed mode (for example, with $page = visit('/')->debug();), I get a Playwright XServer error.
This seems like a missing piece for fully supporting Pest v4 browser tests in Sail.
Steps To Reproduce
-
Clone a Laravel project using Sail with Pest v4 and pest-plugin-browser v4.
-
Run browser tests in headless mode (See: https://pestphp.com/docs/browser-testing#content-running-browser-tests)
./vendor/bin/pest --debugOR run Pest with the debug function in the test
$page = visit('/')->debug(); -
Observe the error below about XServer not running.
Target page, context or browser has been closed
Browser logs:
╔════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Looks like you launched a headed browser without having a XServer running. ║
║ Set either 'headless: true' or use 'xvfb-run <your-playwright-app>' before running Playwright. ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
at vendor/pestphp/pest-plugin-browser/src/Playwright/Client.php:101
at vendor/pestphp/pest-plugin-browser/src/Playwright/Playwright.php:216
at vendor/pestphp/pest-plugin-browser/src/Playwright/Playwright.php:59
at vendor/pestphp/pest-plugin-browser/src/Api/PendingAwaitablePage.php:125
at vendor/pestphp/pest-plugin-browser/src/Api/PendingAwaitablePage.php:45
at
Expected Behaviour
A browser window should open from the Sail environment when running Pest browser tests in headed mode.
Actual Behaviour
Headed mode fails with an XServer missing error.
Thank you for reporting this issue!
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Thank you!
Still having the same issue. Has anyone been able to get this fixed? Thanks.
Having the same issue.
Using Laravel Sail on Omarchy (Arch Linux)