拉拉维尔Phpunit和黄昏与圆环

时间:2022-10-18 21:33:23

Has anybody been able to get Laravel Dusk working on CircleCI.

有没有人能在CircleCI上做一个拉尔维尔的黄昏。

I can get my build working and tested with PHPUnit but it fails for Laravel Dusk.

我可以用PHPUnit来完成我的构建工作和测试,但它不能用于Laravel黄昏。

I have a base Laravel installation with Dusk installed. When I get to the php artisan dusk command, I get the following error.

我有一个安装了黄昏的基础拉拉维尔装置。当我到达php artisan黄昏命令时,我得到以下错误。

Error

错误

1) Tests\Browser\ExampleTest::testBasicExample
Did not see expected text [Laravel] within element [body].
Failed asserting that false is true.

So it is starting the chromebrowser, but isn't hitting the site.

因此,它正在启动chromebrowser,但并没有访问这个站点。

I have tried running with Dusk's chromedriver-linux, circleci's chromedriver, not using php serve and quite the variety of other tweaks. So far, I haven't had any luck.

我尝试过使用黄昏的chromedriver-linux, circleci的chromedriver,不使用php服务和其他各种各样的改进。到目前为止,我没有任何运气。

Here is a link to the repo and the relevant files are posted below.

这里有一个到repo的链接,相关文件贴在下面。

Here is my circle.yml file.

这是我的圈子。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 that I copy to .env

.env。我复制到。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

Screenshot (pulled from circleci and not very helpful).

截图(摘自circleci,不太有用)。

拉拉维尔Phpunit和黄昏与圆环

I found these articles which were helpful, but they did not work for me.

我发现这些文章很有帮助,但对我不起作用。

2 个解决方案

#1


4  

The following code working for us. Try this

下面的代码适用于我们。试试这个

circle.yml file.

圆。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

.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

Output Checkout here

这里输出结帐

#2


0  

This is the configuration that finally worked for me.

这就是最终对我起作用的配置。

circle.yml

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

.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

#1


4  

The following code working for us. Try this

下面的代码适用于我们。试试这个

circle.yml file.

圆。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

.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

Output Checkout here

这里输出结帐

#2


0  

This is the configuration that finally worked for me.

这就是最终对我起作用的配置。

circle.yml

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

.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