What is the difference between a unit test and an integration test?
A unit test exercises one piece of logic in isolation, replacing its collaborators with stand-ins. An integration test exercises several real components together, typically including something external such as a database or an HTTP layer. The distinction is about how much of the real system is involved, and that determines what each kind of test can tell you.
Unit tests are fast, deterministic and precise about failure. When one fails you usually know the exact function at fault. Their weakness is that they verify each part against your assumptions about the others, so a suite of green unit tests is entirely compatible with a system that does not work, because the assumptions were wrong.
Integration tests catch precisely those failures: a query that does not match the schema, a serialisation mismatch between two services, configuration wrong in a way no stand-in would reveal. They are slower, need real infrastructure, and when they fail the cause is less immediately obvious.
The usual guidance is many unit tests and fewer integration tests, on the grounds that fast ones should carry most of the load. That is sound as a default, though the right balance depends on where your risk actually lives. Code that is mostly coordination between a database and an HTTP layer, with little logic of its own, is poorly served by unit tests full of mocks; those mocks end up asserting that the code calls the functions it calls, which is close to testing nothing.
The practical check for whether a unit test earns its place is whether it could fail for a reason you would care about. If it can only break when you deliberately change the implementation it mirrors, it is a maintenance cost rather than a safety net.