It's possible that the test is failing because the search index hasn't been updated yet. Try adding a call to User::searchable() after inserting the data in the setUp() method to ensure that the search index is updated.
Here's an updated setUp() method:
protected function setUp(): void
{
parent::setUp();
$password = Hash::make('password');
// initialize search data
User::insert([
[
'first_name' => 'John',
'last_name' => 'Doe',
'email' => '[email protected]',
'password' => $password
],
[
'first_name' => 'Jane',
'last_name' => 'Doe',
'email' => '[email protected]',
'password' => $password
],
[
'first_name' => 'Foo',
'last_name' => 'Bar',
'email' => '[email protected]',
'password' => $password
]
]);
User::searchable();
}
This should ensure that the search index is updated before the test runs.