Closed zenlex closed 2 years ago
Can you create a project on GitHub where we can reproduce the issue, and re-open an issue here?
I'll try when I get a minute to see if I can repro on a project I can share.
Having the same issue.
@zenlex did you create an example repo? I am experiencing the same issue with the exact same set up (mixture of PHPUnit and Pest) and wondered if a solution/explanation had been found.
Haven't had time to set up a complex enough example to repro the problem yet and on the project where we had the issue we just refactored all the php unit tests to Pest and the problem went away. Have experienced it on more than one project though. No problem mixing php unit and pest as long as they don't both use the refreshDatabase trait.
Having the same issue but no mixed tests 🤔
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 theuse RefreshDatabase
trait. The Pest tests all haveuses(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