Coder Social home page Coder Social logo

zaherg / laravel-dusk Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 15 KB

A PHP 7.x docker image with Composer and xDebug, contains just the minimum required to run Dusk on a CI.

Home Page: https://hub.docker.com/r/zaherg/laravel-dusk/

License: MIT License

Dockerfile 100.00%
php docker php-xdebug php7 continuous-integration continous-deployment continous-delivery laravel-dusk laravel-testing

laravel-dusk's Introduction

PHP image to run laravel dusk tests

Docker Pulls

PHP 7.x image with Composer and xDebug, contains just the minimum required to run Dusk on a CI. So you should use it as the base for your custom image.

Image versions

  1. zaherg/laravel-dusk:latest
  2. zaherg/laravel-dusk:7.2
  3. zaherg/laravel-dusk:7.3
  4. zaherg/laravel-dusk:7.4

Duck configuration:

To make it work, you will need to make sure that you add the argument --no-sandbox to your options so the function should look like

    /**
     * Create the RemoteWebDriver instance.
     *
     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
     */
    protected function driver()
    {
        $options = (new ChromeOptions)->addArguments([
            '--disable-gpu',
            '--headless',
            '--window-size=1920,1080',
            '--no-sandbox'
        ]);

        return RemoteWebDriver::create(
            'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }

xDebug configuration

By default xdebug is enabled, to disable it you need to create a .env file which should contain the following variables, but remember to change the value based one what you want to achieve:

PHP_XDEBUG_DEFAULT_ENABLE=0
PHP_XDEBUG_REMOTE_ENABLE=0
PHP_XDEBUG_REMOTE_HOST=127.0.0.1
PHP_XDEBUG_REMOTE_PORT=9001
PHP_XDEBUG_REMOTE_AUTO_START=0
PHP_XDEBUG_REMOTE_CONNECT_BACK=0
PHP_XDEBUG_IDEKEY=docker
PHP_XDEBUG_PROFILER_ENABLE=0
PHP_XDEBUG_PROFILER_OUTPUT_DIR=/tmp

Then run the docker and specify the env file that you have created like this

docker run --env-file .env zaherg/laravel-dusk:<version>

Bitbucket Pipeline Example

You can read more about it from this post https://zah.me/blog/2018/02/03/running-laravel-dusk-tests-on-bitbucket-the-easy-way/

This is just an example, the content of the file .env.dusk is not different that .env.example except that the APP_URL value is http://localhost:8000 since am using artisan serve command.

APP_URL=http://localhost:8000

Your bitbucket-pipeline.yml should look like this:

# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: zaherg/laravel-dusk:latest


pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - cp .env.dusk .env
          - composer install --no-progress --no-suggest --prefer-dist
          - php artisan serve &
          - php artisan dusk

TODO:

[] Write about using the image with Docker Hub CI.

laravel-dusk's People

Contributors

zaherg avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

danbaugher

laravel-dusk's Issues

Error: This version of ChromeDriver only supports Chrome version 83

Hello

I'm getting the following error when running on Bitbucket Pipelines, can you help?

Facebook\WebDriver\Exception\SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 83
/opt/atlassian/pipelines/agent/build/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:125
/opt/atlassian/pipelines/agent/build/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:370
/opt/atlassian/pipelines/agent/build/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:136
/opt/atlassian/pipelines/agent/build/tests/DuskTestCase.php:42
/opt/atlassian/pipelines/agent/build/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:200
/opt/atlassian/pipelines/agent/build/vendor/laravel/framework/src/Illuminate/Support/helpers.php:393
/opt/atlassian/pipelines/agent/build/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:201
/opt/atlassian/pipelines/agent/build/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:95
/opt/atlassian/pipelines/agent/build/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:65

Our pipeline step is:

      - step:
          name: run-tests
          image: zaherg/laravel-dusk:7.3
          script:
            - cp .env.dusk.local .env
            - php artisan config:clear
            - php artisan config:cache
            - php artisan dusk:chrome-driver
            - php artisan dusk

The output from php artisan dusk:chrome-driver is "ChromeDriver binary successfully installed for version 83.0.4103.39.".

Any help would be much appreciated.

Thanks

Peter

PHP 7.4 support

Hi, This container helps us for running dusk test in the pipeline. Thanks for the great work.

Do you have any plan to support 7.4?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.