They have a little probe in the tip that you touch to the stone. It sends heat into the stone and can measure what the material is based on how it handles the heat, and either a light comes on to identify it or the needle in the bigger versions identifies what the stone is, what kind of simulant or natural stone it is. There are some that can just say Simulant to Diamond, Simulant, Moissanite, Diamond, and beyond. The biggest thing to know is that Moissanite does conduct heat similarly to a diamond, so if you can buy one that can do all three, I would. There are moissanite testers that are specific to just testing for moissanite too. There are so many brands out there but the Presidium I think is the most accurate I've come across. Like cars, they come in several "trim levels". The more advanced professional ones have all kinds of features and things they can identify. There is a GemOro and a Presidium that are like consumer level that really just identify yes or no it's a diamond.
Now, I don't know how they label lab-created diamonds (not to be confused with cz's or whatever, these really are diamonds), as they are diamonds, their origin is just not out of the earth. I would assume they would register as diamonds.