Laravel Test Pass when run single test, but fails when running all tests
Hi, everyone,
So I just got stuck on testing, because when I ran my test individually it got success.
When I run all tests, that test fails.
When I enable processIsolation in phpunit.xml, and run all tests I got success.
Any ideas what might would be?
note: I don't want to use processIsolation because testing time increases 5 times
Show the tests in question :)
/** @test */
public function a_superadmin_can_see_all_users_except_himself_and_other_superadmins()
{
$himself = $this->signIn('superadmin');
$superadmin = $this->new_user('superadmin');
$admin = $this->new_user('admin');
$moderator = $this->new_user('moderator');
$premium = $this->new_user('premium');
$otherUser = $this->new_user();
$response = $this->get(route('user.index'));
$response->assertStatus(200);
$response
->assertDontSee($himself->email)
->assertDontSee($superadmin->email)
->assertSee($admin->email)
->assertSee($moderator->email)
->assertSee($premium->email)
->assertSee($otherUser->email);
}
This is where the test is failing, it fails randomly:
->assertSee($admin->email)
->assertSee($moderator->email)
->assertSee($premium->email)
->assertSee($otherUser->email);
Like, sometimes fails on $moderator->email , other times on $premium->email.
I though this may be happening because of random values on UserFactory so I removed all random values, but it still fails.
This error disappears after update to Laravel 8.
Please or to participate in this conversation.