Running Laravel Dusk in BitBucket Pipelines

I am trying to setup a Laravel 5.4 project in BitBucket Pipelines, with Laravel Dusk test scripts. However, I can't seem to get a successful build. After fixing several issues and finally getting my build to run my test scripts, I am not stuck at :

Screen Shot 2017-08-09 at 5.00.04 PM.png

 

How do I get the Chrome Wed Driver to launch and run the test?

1 answer

1 accepted

There are a couple of issue to address. I faced the same but finally got it working.

The main issue are the chrome drivers and the options to use to fire chrome.

The linux driver is a binary, so it may not be compatible with all the distros. And chrome has to be run in headless mode without gpu.

 

Have a look at the documentation of this docker image:

https://hub.docker.com/r/angelomaragna/networld-dusk/

I built it from Alpine, and with it (395MB unfortunately) I can finally run dusk tests in pipelines.

 

Angelo

Hi @Angelo Maragna, I tried to create a new container for testing using the container link you gave but it was returning me the following error:

Unable to find image 'networld-dusk:latest' locally
docker: Error response from daemon: repository networld-dusk not found: does not exist or no pull access.

So instead, I tried by using the steps described in the link with my existing container that is set up with php7-fpm and is still unable to get my test to run successfully.

Error in my documentation. "networld-dusk" is available on my local becasue I compiled it.

Please use "angelomaragna/networld-dusk" like in

docker run --privileged --name dusk -ti angelomaragna/networld-dusk /bin/sh

This is my bitbucket-pipelines.yml file (you can check that file also inside the docker container)

image: angelomaragna/networld-dusk

pipelines:
  default:
    - step:
        script:
          - rm vendor/laravel/dusk/bin/chromedriver-linux
          # Laravel Dusk driver is not compatible so we replace it with the Alpine one
          - ln -s /usr/lib/chromium/chromedriver vendor/laravel/dusk/bin/chromedriver-linux
          - vendor/laravel/dusk/bin/chromedriver-linux &
          - cp .env.example .env
          - php artisan dusk 

Hi @Angelo Maragna

I finally had the time to give this another try and after many rounds of trial and error, I finally got my first successful build!

Using your image and bitbucket-pipelines.yml as a guide, I had to install a few additional packages in order for things to fully work. Here's the final version of my bitbucket-pipelines.yml file:

image: angelomaragna/networld-dusk

pipelines:
  branches:
    develop:
    - step:
        caches:
            - composer
        script:
          - apk update && apk add php7-xmlwriter php7-pdo_mysql php7-session php7-ctype
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - cp .env.example .env
          - composer install
          - rm vendor/laravel/dusk/bin/chromedriver-linux
          # Replace Laravel Dusk driver Alpine's
          - ln -s /usr/lib/chromium/chromedriver vendor/laravel/dusk/bin/chromedriver-linux
          - vendor/laravel/dusk/bin/chromedriver-linux &
          - export DB_CONNECTION=mysql
          - php artisan key:generate
          - php artisan migrate
          - php artisan dusk
          - vendor/bin/phpunit
services:
          - mysq

Thanks for the help!

Thanks for posting this. I tried to get it going but ran into some issues. For anyone else who's following along you'll need to change the apk repository from edge to v3.7

FROM angelomaragna/networld-dusk:latest
RUN echo http://dl-cdn.alpinelinux.org/alpine/v3.7/main > /etc/apk/repositories &&\
echo http://dl-cdn.alpinelinux.org/alpine/v3.7/community >> /etc/apk/repositories &&\
apk update &&\
apk add php7-xmlwriter php7-pdo_mysql php7-session php7-ctype php7-fileinfo &&\
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

22,622 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you