laravel / dusk

Laravel Dusk provides simple end-to-end testing and browser automation.
https://laravel.com/docs/dusk
MIT License
1.87k stars 319 forks source link

Travis CI builds fail using Dusk 2.0.8 #436

Closed dbudwin closed 5 years ago

dbudwin commented 6 years ago

Before upgrading from 1.1.0 to 2.0.8 my Dusk tests worked on Travis CI, and they still currently work locally when I run them (ChromeDriver 2.34.522932). After I updated, my Dusk tests fail on Travis. When I updated, I followed the documentation and updated my .travis.yml file to be the following:

language: php
sudo: required
dist: trusty

php:
  - 7.1
  - 7.2
  - nightly

matrix:
  fast_finish: true
  allow_failures:
    - php: nightly

addons:
  chrome: stable
  code_climate:
    repo_token: $CODECLIMATE_REPO_TOKEN

branches:
  only:
    - master

services:
  - mysql

before_install:
  - mysql -e 'CREATE DATABASE robohome;'

install:
   - cp .env.testing .env
   - travis_retry composer install --no-interaction --prefer-dist --no-suggest

before_script:
  - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
  - php artisan key:generate
  - php artisan migrate --no-interaction -vvv
  - php artisan passport:install
  - php artisan serve &

script:
  - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --configuration phpunit.xml
  - php artisan dusk

after_success:
    - travis_retry php vendor/bin/coveralls -v

My .env.testing file looks like:

APP_NAME=RoboHome
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost:8000

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=robohome
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

MQTT_SERVER=
MQTT_PORT=
MQTT_USER=
MQTT_PASSWORD=

The errors I get look like:

1) Tests\Browser\DevicesTest::testDevices_GivenUserLoggedIn_VerifyPath
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}

Failed to connect to localhost port 9515: Connection refused

/home/travis/build/dbudwin/RoboHome-Web/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286
/home/travis/build/dbudwin/RoboHome-Web/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126
/home/travis/build/dbudwin/RoboHome-Web/tests/DuskTestCase.php:25
/home/travis/build/dbudwin/RoboHome-Web/vendor/laravel/dusk/src/TestCase.php:210
/home/travis/build/dbudwin/RoboHome-Web/vendor/laravel/framework/src/Illuminate/Support/helpers.php:762
/home/travis/build/dbudwin/RoboHome-Web/vendor/laravel/dusk/src/TestCase.php:211
/home/travis/build/dbudwin/RoboHome-Web/vendor/laravel/dusk/src/TestCase.php:117
/home/travis/build/dbudwin/RoboHome-Web/vendor/laravel/dusk/src/TestCase.php:89
/home/travis/build/dbudwin/RoboHome-Web/tests/Browser/DevicesTest.php:19

My code in question can be viewed here: https://github.com/dbudwin/RoboHome-Web/pull/125 The Travis CI errors can be viewed here: https://travis-ci.org/dbudwin/RoboHome-Web/builds/328614743?utm_source=github_status&utm_medium=notification

I'm not sure why the connection is being refused on 9515. Any suggestions? Thanks!

dbudwin commented 6 years ago

Note, I saw @taylorotwell published some updates today. I upgraded my installation to use Dusk 2.0.10 and I still have the exact same issue as above and hoping someone can spot what's going on.

brianchristopherpeck commented 6 years ago

Try setting the chrome driver that comes with Laravel to executable in your Travis build sudo chmod a+x ./vendor/laravel/dusk/bin/chromedriver-linux Also, you may have to change the port in the Travis build. I had to change it when building in Jenkins

dbudwin commented 6 years ago

@brianchristopherpeck I don't believe the "new" way to run Dusk tests in Travis uses the chromedriver-linux program. See https://laravel.com/docs/5.5/dusk#running-tests-on-travis-ci

driesvints commented 5 years ago

Closing this issue because it's already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue.