RefreshDatabase unstable in mixed PHPUnit / Pest setup
On two separate projects I've run into this issue recently. The Laravel projects in question have mixed test suites with some PHPUnit and some PEST tests, all being run together via artisan test. The PHPUnit tests contain the use RefreshDatabase trait. The Pest tests all have uses(RefreshDatabase::class) bound globally in the Pest.php file.
When running the full feature test suite, sometimes tests that were passing now fail and vice versa without functional code changes. Re-running the tests multiple times will cause the failure to move or disappear altogether. It appears the database refresh is not stable/reliable in this setup. Refactoring the PHPUnit to Pest or vice versa appears to eliminate the issue, as does preventing either the Pest or the PHPUnit tests from refreshing the DB. Running the failing tests in isolation with --filter also makes them pass when this is occurring.
Is there some variance in how the DB transactions/locks/migrations are handled with the PHPUnit tests vs Pest that could be getting out of sync here?
DB is Postgres. Laravel 9, Pest 1.21, pest-plugin-laravel 1.1