Pregnancy test

How many days before your period can you do a pregnancy test? Or is it worth just waiting?!