Testing with Laravel Dusk

Laravel Dusk uses the Chrome browser (in headless mode) to run tests against the rendered HTML/Javascript of your application.

Setting up Dusk in Chipper CI

Dusk sends web requests to the port defined in either APP_URL or APP_DOMAIN environment variables. We'll assume port 8000 will be used for the web server.

This requires the following setup.

1. Environment Variables

Be sure your APP_URL and/or APP_DOMAIN environment variables include the port (8000 in our case):


Note that if your repository includes a .env.dusk.* file, this will override other environment variables. Be sure that if this file exists, it has the correct APP_URL and/or APP_DOMAIN configured and that you use the --env flag in your php artisan dusk command to match this file.

This environment behavior is different from our documented environment precedence and is the result of how Dusk works.

2. Pipeline Step

Dusk requires a web server to be running in order to send web requests to it.

Please use the following script to run your Dusk tests:

# Important: Update the chrome driver version to the build container's
# current version of google-chrome
GOOGLE_CHROME_VERSION=`google-chrome --version | cut -d " " -f3 | cut -d "." -f1`
php artisan dusk:chrome-driver $GOOGLE_CHROME_VERSION

# Listen on port 8000 for web requests
# Use this instead of "php artisan serve"
php -S -t public 2>/dev/null &

php artisan dusk

You can tweak this as needed, for example if you want to set a specific environment to Dusk: php artisan dusk --env=ci