End-to-end tests that need a real SMS code have one job that is easy to get wrong: waiting. Wait too little and the test fails on a slow carrier. Wait too long and a broken run blocks your pipeline for 15 minutes. Here is the polling pattern we use against a receive-SMS API, with the reasoning behind each number.
The shape of the flow
Buy (or rent) a number for a specific app and country.
Enter it in the sign-up form under test.
Poll for the SMS until it arrives or a deadline passes.
If nothing arrived, cancel the number so you are not charged, and fail the test with a clear message.
The API in these examples is ours (receive-smss.net, base https://receive-smss.net/api/v1 , Bearer token), but the pattern works with any provider that has "get number", "read SMS" and "cancel" calls.
Poll with a deadline, not a retry count
Retry counts hide the real budget.…