So who wants to hear from a professional mechanic about all this?
The "check engine" light sometimes has very little to do with how well the car feels like it's running. The light's main purpose is to tell when the computer has detected a failure in an emission control system. And if there's a failure in a computer controlled/monitored emission control system, then of course you fail an emission test.
The old clear the code and then go get the test done before the light comes back on trick sounds good, but unfortunately there's a catch. By clearing the codes, or clearing the computer's memory, you erase another memory. There's several self tests that the computer does on the emission control systems. They're called monitors. Part of the smog test is to see if the montiors have all run and passed. Of course if a monitor runs (which takes two complete drive cycles) and doesn't pass. then the check engine light comes on. There's no way around it. Other than maybe finding a shop that just looks the other way.