dongpa5207 2018-09-20 14:19
浏览 59
已采纳

Laravel黄昏,测试结果不正确

I just discovered Laravel Dusk, and wrote first test, which had to check for text on the page, but Laravel Dusk doesn`t see my page.

Test:

namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class FirstTest extends DuskTestCase
{
    public function testExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                ->assertSee('Laravel');
        });
    }
}

And $browser->visit('/') check is successful, but $browser->visit('/') ->assertSee('Laravel'); check was failed.

In directory tests/Browser/Screenshots I found screenshot that page, which contains No input file specified

a part of file .env:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:lypVdWwGkDn/R5L5PQ8tOUgfzf2WTzCSZU6GndMPuNM=
APP_DEBUG=true
APP_URL=http://127.0.0.1

After added file .env.dusk.local which contains:

APP_URL=http://127.0.0.1:9519

(As specified in the Laravel Dusk manual , the port must match the one specified in DuskTestCase.php)

tests/Browser/screenshots/failed-test-* contains: command:

Error text:

Time: 2.58 seconds, Memory: 12.00MB

There was 1 failure:

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

/home/vagrant/code/homestead_test/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:400 /home/vagrant/code/homestead_test/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:371 /home/vagrant/code/homestead_test/tests/Browser/FirstTest.php:18 /home/vagrant/code/homestead_test/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:67 /home/vagrant/code/homestead_test/tests/Browser/FirstTest.php:19

FAILURES! Tests: 1, Assertions: 1, Failures: 1.

Sorry for my English =)

UPD:

a part of .env.dusk.local after deleting port: (for Jonas Staudenmeir).

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:lypVdWwGkDn/R5L5PQ8tOUgfzf2WTzCSZU6GndMPuNM=
APP_DEBUG=true
APP_URL=http://127.0.0.1
  • 写回答

2条回答 默认 最新

  • douxi8119 2018-09-21 07:33
    关注

    Solved. I changed .env.dusk.local (was set virtual host domain), and it's working.

    e.g. APP_URL=http://homestead.test

    Special thanks to @Jonas Staudenmeir

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?