How early can you take a pregnancy test?

I have very irregular periods. I'm not TTC but I have been feeling very off. Like my boobs are killing me. And the only symptom I get before I get my period is back pain. But I was just curious cause my period come anywhere from 40 to 65 days apart. So I was wondering when the earliest I could take a test?