sail icon indicating copy to clipboard operation
sail copied to clipboard

Pest v4 browser tests fail in headed mode on Sail (WSL): XServer not running

Open OsitaDNU opened this issue 6 months ago • 3 comments

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

  1. Clone a Laravel project using Sail with Pest v4 and pest-plugin-browser v4.

  2. Run browser tests in headless mode (See: https://pestphp.com/docs/browser-testing#content-running-browser-tests)

    ./vendor/bin/pest --debug
    

    OR run Pest with the debug function in the test

    $page = visit('/')->debug();
    
  3. 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.

OsitaDNU avatar Sep 07 '25 17:09 OsitaDNU

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!

github-actions[bot] avatar Sep 08 '25 13:09 github-actions[bot]

Still having the same issue. Has anyone been able to get this fixed? Thanks.

antero111 avatar Nov 07 '25 07:11 antero111

Having the same issue.

Using Laravel Sail on Omarchy (Arch Linux)

backstageel avatar Nov 30 '25 07:11 backstageel