Menu

Polling for an SMS code in tests without flakiness: deadlines, intervals and refunds
📰

Polling for an SMS code in tests without flakiness: deadlines, intervals and refunds

DEV Community: python·Receive SMS·about 2 hours ago
#EeieSD9b
#devtopython#devto#dev#number#test
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.