It's a brand new day when you are accounting for four PCR tests in order to leave the country just once. Though the airline, departing country and entry country all have their own COVID-19 testing requirements—how complicated!1—the general consensus is most travelers will need to test at least 72 hours in advance or less of a trip.
When that test is taken is more up for discussion. Realistically, same-day testing at the airport right before a flight should be avoided because it is by far the worst place to receive a positive result.
Turns out there is a thing as too late, even though it might be the most accurate snapshot of affairs.
Not only is testing at the airport super last-minute, in some countries like Portugal, travelers are immediately detained and quarantined. It's part of the protocol.
Look, if you are going to test positive and be detained, it's better to do it on your own terms rather than someone else's. (Book travel insurance.)
Though Portugal is only one example, it's not worth playing the chance with other countries either.
Here is a quick excerpt for the U.S. embassy's website:
Mandatory Quarantines and Testing Requirements in effect. Attempts to exit customs or board a flight with a positive COVID test will result in a ten-day quarantine at the traveler’s expense. U.S. citizens using the same-day testing option at the airport and receiving a positive COVID test result will be detained, sometimes for hours, until transportation and quarantine accommodation can be arranged at the traveler’s expense. For this reason, we strongly discourage same-day testing at the airport.
For what it's worth, be prepared to book the follow-up COVID-19 test in advance of departing too. It might be required before boarding and clearing customs.