[英]Laravel Phpunit and Dusk with CircleCI
有誰能夠讓Laravel Dusk在CircleCI上工作。
我可以使用PHPUnit進行構建並進行測試,但是Laravel Dusk失敗了。
我有安裝了Dusk的基本Laravel安裝。 當我到達php artisan dusk
命令時,出現以下錯誤。
錯誤
1) Tests\Browser\ExampleTest::testBasicExample
Did not see expected text [Laravel] within element [body].
Failed asserting that false is true.
因此,它正在啟動chromebrowser,但未訪問該網站。
我試過使用Dusk的chromedriver-linux,circleci的chromedriver來運行,而不使用php serve和其他各種調整。 到目前為止,我還沒有運氣。
這是倉庫的鏈接,相關文件在下面發布。
這是我的circle.yml
文件。
machine:
hosts:
dusk.dev: 127.0.0.1
timezone: America/Los_Angeles
services:
- mysql
environment:
APP_ENV: testing
APP_KEY: randomq2VjceHV2t1Usdskeksa9yUI6a
post:
- chromedriver:
background: true
dependencies:
override:
- composer install --prefer-dist --no-interaction
post:
- mv .env.example .env
test:
override:
- vendor/bin/phpunit
# - ./vendor/laravel/dusk/bin/chromedriver-linux:
# background: true
- sudo php artisan serve --host=localhost --port=80:
background: true
- php artisan dusk
.env.example
,我復制到.env
APP_ENV=local
APP_KEY=base64:BaGXvpvUWnUbGA1RiOapw45K2UCK8AeYM3o62IDV9Qw=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
屏幕截圖 (從circleci中拉出,效果不是很好)。
我發現這些文章很有幫助,但對我沒有用。
以下代碼為我們工作。 嘗試這個
circle.yml文件。
machine:
pre:
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
- sudo apt-get update
- sudo apt-get install google-chrome-stable
services:
- mysql
dependencies:
override:
- composer install --prefer-dist --no-interaction
post:
- mv .env.testing .env
test:
override:
- vendor/bin/phpunit
- ./vendor/laravel/dusk/bin/chromedriver-linux:
background: true
- php artisan serve:
background: true
- php artisan dusk
.env。測試
APP_ENV=local
APP_KEY=base64:BaGXvpvUWnUbGA1RiOapw45K2UCK8AeYM3o62IDV9Qw=
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=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
這是最終對我有用的配置。
circle.yml
machine:
pre:
- sudo apt-get update; USE_PRECOMPILE=true sudo -E circleci-install php 7.0.4
php:
version: 7.0.4
services:
- mysql
post:
- chromedriver:
background: true
dependencies:
pre:
- sudo composer self-update
post:
- cp .env.dusk.testing .env
- php artisan serve:
background: true
general:
artifacts:
- "tests/Browser/screenshots"
- "tests/Browser/console"
test:
override:
- vendor/bin/phpunit
- php artisan dusk
.env.dusk.testing
APP_ENV=testing
APP_KEY=base64:Secr3tSecr3tSecr3tSecr3tSecr3tSecr3tSecr3tSe
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=circle_test
DB_USERNAME=ubuntu
DB_PASSWORD=
MAIL_DRIVER=log
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.