How to use Laravel Dusk with Homestead on a Windows machine

How to use Laravel Dusk with Homestead on a Windows machine

Alongside Laravel 5.4 update, a new tool came up : Laravel Dusk.

If you were used to run tests on your Laravel application, and particularly "Feature tests", you are most likely used to write test cases in which you can actually fill forms, click buttons, and expect to see a specific result.

After upgrading your Laravel application to 5.4, all those nice method (visits, clicks, etc.) are gone. They were moved to a new Laravel package : Laravel Dusk.

Why ?

Because Dusk can actually test javascript based actions and results, so you can now unittest that.

Now, if you are a windows user and you use Homestead for your local development, you'll have some issues with Dusk.

That is because your VM cannot properly open a browser and run the tests as it should be on a normal environement.

Solution in few lines :

SSH into homestead

vagrant ssh

Execute these lines

sudo dpkg –i google-chrome-stable_current_amd64.deb
apt-get install -y xvfb

Edit vendor/laravel/dusk/src/SupportsChrome.php. I know it's bad, but for now it's the only solution. We need to wait for a package update.

From :

// Line 51

To :


Now try to run php artisan dusk again, and it should work correctly.

Note : I was using the last version of Homestead.

I hope it will work for you, and I hope the package will be fixed soon. Happy testing !