How do mechanics test problem that are only happening under load? My singlespeed bike emits a creaking noise(coming from somewhere in the drivetrain) while I'm riding on it, however it doesn't when pedaling on the repair stand.

This question is not about this problem but it made me wonder how do mechanics test to find the problem and verify that they fixed it?

Do they check every pieces of the drivetrain to find a potential problem needing to be fixed? Not knowing whether it is this problem causing the noise.

Do they go out and ride it to try to reproduce the noise?

Do they have some way to apply power on the transmission while on the repair stand? (With a bike trainer or similar)
With most noise-diagnosing, my usual protocol is to test ride thoroughly, including on an uphill, as the first step, to try and get the most accurate impression possible of what the customer is experiencing. You kind of need to do that to know, or at least have a pretty good guess, that you've taken care of the issue at the end. A caveat here is for my own safety (people ride some sketchy stuff) I may torque crank and stem bolts first, which can in theory throw off the before/after picture, but oh well.

I think this is the best practice, but it's also not altogether unreasonable on a lot of creak-fest modern road and mountain bikes (integrated headset and unthreaded BB) to just do all your disassembly/parts replacement/grease-slathering up front and then see what you get afterward. If a customer tells me there are multiple creaks on such a bike or if I can pick up on it from just handling the bike, I might go that route.

There aren't really any ways of simulating load in the stand. There are a few tricks useful for isolating noises in the headset and bottom bracket areas involving sideloading or selectively loading certain areas with the bike on the ground, but they don't simulate full riding loads so they're not a substitute for test riding.