Late period

So when should I take a pregnancy test. I'm about 5 days late. But I cant be certain if my period is just late just because It's usually irregular but the past 2months or so its been pretty accurate. So I'm so confused. I wished this app could calculate when its a perfect time to take a test.. especially if you say your period hasn't come yet.. I'm so nervous to take the test cause I really wanna be pregnant. But I also dont want to have another miscarriage. . Im so lost