create laravel LoginTest class using below artisan command:
php artisan dusk:make LoginTest
<?php
namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use App\Models\User;
class LoginTest extends DuskTestCase
{
/**
* A Dusk test for user login.
*
* @return void
*/
public function testUserLogin()
{
$user = factory(User::class)->create([
'email' =>'[email protected]',
]);
$this->browse(function (Browser $browser) use ($user) {
$browser->visit('/login')
->assertSee('Login')
->value('#email', $user->email)
->value('#password', $user->password)
->press('Login')
->assertPathIs('/home')
->assertSee('You are logged In!');
});
}
}
Now run below command to test the test cases:
php artisan dusk