Running Laravel Dusk tests on Bitbucket, the easy way

So today I was trying to run and see if I can manage to get Laravel dusk to run on Bitbucket pipelines, and after too many tests, I was able to do so \(^ ^)/.

In this post I’ll explain the minimum requirements you need to do that, to make things simple, I created a docker image based on PHP 7.2 that you can use directly.

Configure your Laravel project:

After installing Laravel and Laravel dusk (you can read all about it on the docs), you can create a new environment file called .env.dusk which contain the following:

as you can see its the same as .env.example file except that the APP_URL value is different.

Second, configure Dusk:

By default Dusk, wont work on bitbucket-pipelines, so you should add --no-sandbox to your options argument in DuskTestCase file so the dirver function should be something like :

Third Configure Bitbucket Pipelines:

Your bitbuekt-pipelines.yml file can contain the following:

as you can see, we install the packages, run artisan serve and then run artisan dusk

Thats all.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: