In certain counties of Maryland we have an emissions test, and it's a similar thing. If the battery has been disconnected recently, or you used a code reader to reset any error codes, you run a strong risk of not passing the emissions test. You won't fail, but they'll tell you they can't get the readings they need, and tell you to come back, something like 8 or more days later, free of charge.
Back in 2016, I had a 2000 Park Ave that had the check engine light on. It had a ton of other issues, so that was the least of its worries. The emissions test was due soon. The check engine light miraculously went out on its own early one morning, so I figured I'd take a chance and take it to the emissions test. And damn if it didn't pass!
Well, fast forward to 2022. I had a 2003 Regal that tended to eat MAF sensors and other emissions equipment like they were Skittles. Its check engine light was on. I read the codes, and it was, once again, the MAF sensor. I used the code reader to clear out the codes, and turn off the light. Four days later, when I took the car through the emissions test, the guy asked me if this car sits unused a lot? I said yeah, I work from home, so I don't really drive much. He said it was a common thing in GM cars of that era to lose some of their memory if they're not driven enough. Told me to try driving it around more, and through a variety of scenarios (short trip, out on the highway a bit, and so on) and I could come back in 8 days.
So, I tried that. I was sweating bullets the whole time, worried that damn light would come back on. But, it went the whole 8 days, and next time I took it through the test, it passed! The light did come back on a couple days later, though.
It sounds like some of these annual state inspections are even more nitpicky than this, though, when it comes to reading codes/history from the car's processor.