Was watching a video on YT where the guy videoing stated that these roadside smog checks are unconstitutional and you're within your rights to say that you don't consent to it being done. They have to have a valid reason to pull you over. If you don't consent, you're free to go!
As someone who works in the court system (California). This is not entirely accurate.
A smog check or just under the hood inspection is legal. It is considered a lawful order from an officer because it is a vehicle equipment inspection. Vehicle equipment inspections do not require a search warrant of any sort. The same way an officer can pull you over, because he thinks your tint is too dark and he wants to check, is the same way that applies to smog or equipment under the hood. If you deny an officer a request you are technically committing a Felony in the state of CA. Will you get one? Probably not, because the paperwork for a Felony vs a smog is A LOT. However, I have seen cases where officers have given a Felony if they are petty enough. I have also seen misdemeanor tickets given in these situations as well.
My best advice, Don't drive like a dummy, always keep Waze open even on regular commutes, and if you do get stopped you should just comply. You are HEAVILY rolling the dice if you do not and the odds are not in you favor.
I say this to you as someone who has owned a straight piped integra, s2000, mustang and R6. I have been pulled over probably 40+ times in my life and only ever received 6 tickets and most were just front plate tickets. I never deny the officer a chance to pop the hood and all of my cars have had obvious illegal modifications.
also please keep in mind laws very from state to state.