I do electronics as a hobby. I sometimes buy chips from very dubious shops in China for fun. Some of these sources are sketchy even by Taobao/Aliexpress standards. Then I decap the chip by boiling the package in acid and inspect the die under a microscope. More than half of them are genuine. I get some nice surprises because even the chips that I expect to be absolutely fake can turn out to be genuine.
So far I've seen a ton of fake audio op-amps.
For discrete parts like transistors things are much simpler. Just build a simple test rig and test a few parameters. If they fall within the specs they're probably good enough. Of course it's not worth it to do this for jellybeans like 2N3904, but when some parts get obsoleted without a replacement (or they're too pricey) there isn't much else a lone hobbyist can do.