Deploying straight from a passing test suite to production skips an entire category of problems: tests mock things (external APIs, sometimes the database, third-party payment providers) that a staging environment — a near-identical copy of production's infrastructure — doesn't. A common pattern:
main → auto-deploy to staging (low risk, easy to revert, safe to break).Staging environments earn their cost specifically by catching the class of bug that only exists at the boundary between your code and the real world it talks to — a third-party API that behaves subtly differently than its mocked test double, a database migration that runs fine against a small test dataset but times out against a production-sized one, a configuration value that's correct in every environment except the one you forgot to update. None of that shows up in a unit test, no matter how good the unit test suite is.