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 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看