Your BMW will not pass the smog check with the check engine light on. It will also not pass the smog test if you recently cleared the Air Injection trouble code (P0491), turned off the check engine light, but did not allow enough drive time to reset or complete the Emission Monitors. In order to pass the smog inspection you'll need to repair the Secondary Air Injection fault. Clear the trouble code. Then drive your car for 200-300 miles over the course of a week (in all traffic conditions) in order to set the emissions monitors (also known as readiness flags).
Emission Monitors are internal self-tests which the smog machine will look for to make sure your BMW's emission systems are functioning properly.