laravel / dusk

Laravel Dusk provides simple end-to-end testing and browser automation.
https://laravel.com/docs/dusk
MIT License
1.88k stars 323 forks source link

Error message when running dusk on a fresh laravel install #1140

Closed voidgraphics closed 2 weeks ago

voidgraphics commented 2 weeks ago

Dusk Version

8.2

Laravel Version

11.26

PHP Version

8.3.11

PHPUnit Version

11.3.6

Database Driver & Version

No response

Description

Error message when running php artisan dusk on a fresh laravel install:

Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--window-size=1920,1080","--disable-search-engine-choice-screen","--disable-gpu","--headless=new"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","goog:chromeOptions":{"args":["--window-size=1920,1080","--disable-search-engine-choice-screen","--disable-gpu","--headless=new"]}}}

Failed to connect to localhost port 9515 after 0 ms: Couldn't connect to server

CleanShot 2024-10-03 at 11 45 41

Steps To Reproduce

laravel new dusk-project # I chose Pest as the testing framework, don't know if it also fails with phpunit
cd dusk-project
composer require laravel/dusk --dev
php artisan dusk:install
php artisan dusk
crynobone commented 2 weeks ago

Can you run php artisan dusk:chrome-driver --detect and try again

voidgraphics commented 2 weeks ago

Of course. The problem persists:

CleanShot 2024-10-03 at 14 10 21

voidgraphics commented 2 weeks ago

I don't really understand what just happened but here it is: on my colleague's machine, the prepare method of DuskTestCase is never called, so it does not start the chrome driver process. I suspected the same was happening to me, so I added a dd('test') to it, and it did show on my machine.

CleanShot 2024-10-03 at 14 18 58

The interesting part is that after removing the dd(), now dusk seems to work:

CleanShot 2024-10-03 at 14 17 40

I did not change anything really.

crynobone commented 2 weeks ago

It's hard to debug what's missing on the initial install. not calling prepare() might indicate and old PHPUnit installs. The error earlier might indicate missmatch version between Chrome and ChromeDriver.

voidgraphics commented 2 weeks ago

The prepare issue is indeed on an older project, but that problem is different, let's ignore it for now.

I tried making yet another fresh Laravel project, and doing the exact steps I described before:

laravel new dusk-project # I chose Pest as the testing framework, don't know if it also fails with phpunit
cd dusk-project
composer require laravel/dusk --dev
php artisan dusk:install
php artisan dusk

I still get the dusk error. However, running php artisan dusk a second time, it works: CleanShot 2024-10-03 at 14 40 39

I tried doing this on two different machines and I get the same result.