Rather than testing the output of someTests are not limited to verifying application logic executed in memory. If all your test does is verify calls to mocks, then you wantare verifying implementation. You are right to verifyquestion the outputvalue of making that call tosuch tests for the very reasons you mention in your question. This happens at the boundaries between your application and some other system, like a database or web API. There tends to be very little logic to test. That doesn't mean tests are not valuable, file systemthough.
Instead of using mocks, oruse the real thing — an actual database. This is a perfectly valid technique for testing infrastructure modules or web service. While testing terminology isn't standardized, you'll hear many people call this a form of integration testing. You are still testing the output, but not the output of a function in your program. You are testing the output generated by two or more systems working together.
These kinds of tests run slower than what you classify as a unit test. That's ok. Just don't run these tests as often. Be careful when running integration tests against a shared resource, so one test does not interfere with the output of another. File paths, database connection strings and URLs to web service should be parameterized so you can run tests against a local database, temp files, or a local copy of a web service.
That doesn't mean you cannot run tests against a shared resource. This might be desirable in a CI/CD build, but this becomes a matter of configuration and deployment.
At some point there is no benefit to mocking function calls. You need to test the real thing.