Using Dusk with Laravel

Laravel 5.4 has introduced some great new features, but I think one that’s really impressing a lot of people is a new package called Dusk.

I had a few problems setting it up, so here’s some things to check if you’re having problems.

Make sure you’ve installed Chrome

This may sound stupid, but I don’t have Chrome installed – I tend to use Safari and Firefox. This caused a problem when running locally on my Mac, as you might imagine.

Check permissions

Dusk is installed via Composer, but it doesn’t set the binary to the correct permissions to be used by Artisan, if you’re using it locally rather than in the box you installed it from. For example, you installed it using a Vagrant box (like Homestead), but you’re running your tests locally on your computer.

This will fix that problem:

chmod -R 0755 vendor/laravel/dusk/bin

Check your .env file has the correct APP_URL

You often forget to do this at the start of your project, but check your .env file for APP_URL. It has to be correct for Dusk to be able to load the page.