Skip to content

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

@OsitaDNU

Description

@OsitaDNU

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions