Car inspection question - check engine light 50 characters

Can a car pass inspection if it has a check engine light on? My stupid car keeps throwing a code for a stupid O2 sensor and I’m wondering if I’m going to have to replace it to get it to pass inspection. Thanks!