Could I have had a miscarriage?

Tee

I was 20 days late for my period and my partner and I have been having unprotected sex without birth control for a few months. I took tests whilst I was late but they came out as invalid. I was just about to get some more but I started cramping really bad and now I’ve started my period. I’ve heard of things like missed miscarriages and stuff, could this have happened? Is that why the tests wouldn’t show? I will be going to the doctors soon.