2017-04-19 46 views
6

有没有人能够得到Laravel DuskCircleCI上工作。Laravel Phpunit和CircleCI的黄昏

我可以让我的构建工作并使用PHPUnit进行测试,但Laravel 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,但没有击中部位。

我试过运行黄昏的chromedriver-linux,circleci的chromedriver,没有使用PHP服务和相当多的其他调整。到目前为止,我还没有运气。

这里是链接到repo和相关文件张贴如下。

这是我的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拉,不是非常有帮助)。

enter image description here

我发现这些文章这是有帮助的,但他们并没有为我工作。

+0

尝试的PHP版本添加到您的circle.yml文件'PHP:版本:5.6.5'你的时区后 –

+0

@AmrAly感谢您的建议,但它具有相同的错误。 – whoacowboy

+0

这只是一个建议,但尝试将'dusk.dev:127.0.0.1'更改为'dusk.dev:localhost'或'dusk.dev:0.0.0.0' – NullDev

回答

4

下面的代码为我们工作。试试这个

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.testing

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 

输出Checkout here

+0

感谢您的回答。我有'sudo php artisan serve',我需要删除'sudo'。 – whoacowboy

0

这是最终为我工作的配置。

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。测试

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