how early can you take a pregnancy test?

What is the earliest you can take a pregnancy test and it be accurate???