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