These massive companies do employ a significant reliance on test automation. This approach is paired with sophisticated build tools and supporting infrastructure to make it possible to meaningfully test proposed changes, and ensure that they do not break any downstream projects.
edit: This comment I made recently is relevant, since it speaks to the motivations for using a monorepo and trunk-based development within a business: https://news.ycombinator.com/item?id=41293123