Well, ain't this a hard one?
This depends a lot on your stack. If you have a huge ecosystem with lots of different nodes, you simply can't. And shouldn't. If you have memory or CPU intensive services, you also can't. Otherwise, just install all the software you use, optionally skipping the VM/container layer (ie. install everything directly on your machine.)
Last time I had to test a piece of code that communicates with a Cassandra database. Cassandra, like many Java based software, is a real memory hog, but that can be reduced by changing its config. Obviously this comes with a performance downside, but at least I could make it work.
Also, the library we use to communicate with Cassandra has a well defined interface. For unittests, I made another library that has the same interface, but stores everything in memory. For local testing I made another one that communicates with MongoDB instead, as it is a bit less memory intensive.
There are a lot of possibilities, but it all depends on your stack.