Running Dusk tests on Travis CI and CircleCI
Published on by Mohamed Said
However, it wasn’t very clear how to run Dusk tests on different Continuous Integration services, so I went ahead and tried to run those tests on Travis CI and CircleCI and was able to get it to work.
Running dusk tests on Travis CI
To be able to run the tests on Travis CI, we need to use the sudo-enabled Ubuntu Trusty environment which has the correct chrome version Dusk’s standalone chromedriver needs.
We also need to use Xvfb which is an in-memory display tool that will allow us to run an actual browser on the display-less environment Travis provides, and finally we’ll have to manually run the standalone chromedriver before we run our tests.
.travis.yml file may look like this:
sudo: requiredlanguage: phpdist: trustyphp:- 7.1install:- travis_retry composer install --no-interactionbefore_script:- export DISPLAY=:99.0- sh -e /etc/init.d/xvfb start- ./vendor/laravel/dusk/bin/chromedriver-linux &- cp .env.testing .env- php artisan serve &script:- php artisan dusk
Running dusk tests on CircleCI
On CircleCI it’s even easier, all we need to do is manually run the standalone chrome driver and use
php artisan serve to start start PHP’s built-in server:
machine:pre:- sudo apt-get update; USE_PRECOMPILE=true sudo -E circleci-install php 7.1.0php:version: 7.1.0dependencies:override:- composer install --no-interactiontest:pre:- "./vendor/laravel/dusk/bin/chromedriver-linux":background: true- cp .env.testing .env- "php artisan serve":background: trueoverride:- php artisan dusk