lundi 9 septembre 2019

Laravel Dusk login testing

I copied the code:

public function testBasicExample()
{
    $user = factory(User::class)->create([
    'email' => 'taylor@laravel.com',
    ]);

    $this->browse(function ($browser) use ($user) {
    $browser->visit('/login')
        ->type('email', $user->email)
        ->type('password', 'password')
        ->press('Login')
        ->assertPathIs('/home');
});
}

Source: laravel.com/docs/6.0/dusk

And all the time I get the error:

1) Tests \ Browser \ LoginTest :: testBasicExample
Actual path [/ login] does not equal expected path [/ home].
Failed asserting that '/ login' matches PCRE pattern "/ ^ \ / home $ / u".

web.php

Route :: get ('/', function () {
    return view ('welcome');
});
Route :: post ('/ user', 'UserController @ store');
Auth :: routes ();
Route :: get ('/ home', 'HomeController @ index') -> name ('home');

In phpunit.xml I added:

<env name = "DB_CONNECTION" value = "sqlite" />
<env name = "DB_DATABASE" value = ": memory:" />

What could be the reason for the error?

Aucun commentaire:

Enregistrer un commentaire