DEV Community

Cover image for How to test SMS verification (OTP) flows without using your personal phone number
SMSPing
SMSPing

Posted on

How to test SMS verification (OTP) flows without using your personal phone number

If your app sends one-time codes by SMS, you eventually need to test the whole flow end to end: request a code, receive it, type it in, handle expiry and resend. Using your own phone number for that gets old fast, and it doesn't scale to QA teams or multiple countries.

Options

1. Provider test numbers. Twilio, Firebase Auth and most SMS providers offer magic test numbers or fixed test codes. Great for unit and CI tests, because nothing is actually sent. The downside: you never exercise real carrier delivery.

2. A dedicated SIM or device farm. Realistic, but you're limited to the countries and carriers you physically have.

3. Online virtual numbers. Services that rent you a real number for a short time and show incoming SMS in a web dashboard or API. Useful for checking real delivery, country-specific formatting, sender IDs and latency across regions.

What to check in a real-delivery test

  • Time from request to delivery, per country
  • The sender ID and message template actually shown on the handset
  • Code expiry and resend rate limits
  • Unicode/localized templates (e.g. Chinese, Arabic) render correctly
  • Your app handles a code that never arrives

A note on the tool I built

Disclosure: I run SMSPing, an online SMS receiving service. You pick an app, country and carrier, get a virtual number, and read the SMS in your orders or via API. Pricing is shown upfront, and if no SMS arrives the fee goes back to your balance. Whether a number is accepted depends on each platform's own rules, so for your own app's QA it's a quick way to test real delivery in other countries.

What do you use for OTP testing? I'd love to hear other setups in the comments.

Top comments (0)