RefreshDatabase runs tests inside a transaction or re-migrates the database, which can leave extra records (seeded data, globally scoped models, or observer-created users) visible during the request.
Because of that, your search endpoint returns more than one user, causing assertJsonCount(1, 'data') to fail.
DatabaseTruncation fully wipes the tables between tests, so only the factory-created user exists and the assertion passes.
@miladghorbani1999 the problem that it slows the testing , on the other hand when I used DatabaseRefresh trait with SQLite it works without any problem
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.