pest icon indicating copy to clipboard operation
pest copied to clipboard

Run Browser tests in headed mode when using Sail

Open backstageel opened this issue 3 months ago • 3 comments

I use Laravel Sail in my development environment and I am wondering if there is any way to run Pest Browser tests in headed mode(view the browser interactions) on that setup.

My tests run using "sail artisan test" without problem, even the browser tests. But since I am using Sail, I cant just run "./vendor/bin/pest test --debug" because it can't find the database connection. Running "sail artisan test --debug" complains about not having a Xserver.

Is there any way to make it work? Like redirect sail to open the browser from the host?

backstageel avatar Oct 21 '25 15:10 backstageel

Has someone been able to get this fixed? Still having the same issues.

antero111 avatar Nov 07 '25 08:11 antero111

Hello! I was able to get the headed display to work on sail based on this blog post: https://www.istogram.com/blog/pest-browser-testing-with-laravel-sail-on-wsl2

I added this on my docker-compose.yml:

environment: DISPLAY: ':0' volumes: - /tmp/.X11-unix:/tmp/.X11-unix:rw

Afterward I ran this command in the terminal: xhost +local:docker

Hope it helps!

Edit: I'm on a native Ubuntu machine

edgarandrade-ib avatar Nov 11 '25 11:11 edgarandrade-ib

Hello! I was able to get the headed display to work on sail based on this blog post: https://www.istogram.com/blog/pest-browser-testing-with-laravel-sail-on-wsl2

I added this on my docker-compose.yml:

environment: DISPLAY: ':0' volumes: - /tmp/.X11-unix:/tmp/.X11-unix:rw

Afterward I ran this command in the terminal: xhost +local:docker

Hope it helps!

Edit: I'm on a native Ubuntu machine

I've tried this but got no luck, nothing happens, Ubuntu 25.10 (I'm not running sail but a "custom" Docker setup too)

0x346e3730 avatar Nov 17 '25 04:11 0x346e3730