Laravel Pest Testing
Authenticating a user before running tests.
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
uses(RefreshDatabase::class, WithFaker::class);
beforeEach(function () {
$this->user = User::factory()->create();
$this->actingAs($this->user);
});