janduano's avatar

Problem running Laravel Dusk test in Travis

Hello everyone, I'm trying to get Travis to run the Dusk test, but I always get an error. The tests work well on my local environment, but when Travis run the Test I get an error like this: NoSuchElementException: no such element: Unable to locate element:

Travis configuration:

sudo: required
language: php
dist: trusty

php:
  - 7.1

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

before_script:
    - export DISPLAY=:99.0
    - mysql -e 'create database test;'
    - sh -e /etc/init.d/xvfb start
    - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost:8000 &
    - ./vendor/laravel/dusk/bin/chromedriver-linux &
    - php artisan serve > /dev/null 2>&1 &

script:
    - php artisan dusk

.env.travis

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:30ZWK9OIZNC68ySA163UzSBRC1ckdgk5TZjr9hyHQ+A=
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=test
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync

MAIL_DRIVER=log
0 likes
1 reply
monahajt's avatar

having the same issue

this was fixed for me by running the compile script. in my case, it was npm run dev, obviously it will be unique for each app

Please or to participate in this conversation.