Phone-first sign-up is common across Asia: an 11-digit number and an SMS code in China, a mobile number and a one-time code in India and Pakistan, and in Indonesia often a code by WhatsApp. To test it you need codes that arrive every time, quickly, for numbers you control. Real SMS gives you none of that reliably.
Why real SMS is hard to test with
- Registration before sending. India requires businesses to register their sender ID and message templates (DLT) before SMS are delivered. In mainland China, SMS signatures and templates are approved by the provider before use.
- Real-name SIMs. In China and Pakistan a SIM card is registered to a person’s ID, so a team can’t simply buy a stack of test numbers.
- Cost and delays. Every test run pays for messages, and delivery can take seconds or minutes.
- Virtual numbers refused. Lookup services can tell a virtual (VoIP) number from a mobile one, and many apps refuse virtual numbers before sending a code, as bots use them. Online SMS services hand out exactly those.
Option 1: your auth provider’s test numbers
Most auth providers let you register test numbers that take a fixed code and never send a message:
- Firebase Authentication: add up to 10 fictional numbers, each with a 6-digit code, under Phone numbers for testing in the Phone provider’s settings. No SMS is sent.
- Supabase Auth: add test numbers and their codes under Authentication → Sign In / Providers → Phone, in Test Phone Numbers and OTPs, with a date they stop working. An SMS provider must still be set up, but no SMS is sent.
- Clerk: in development, numbers from +1 (XXX) 555-0100 to 555-0199 take the code 424242.
Keep these in development and staging projects. A production project should have none.
Option 2: a test-mode code in your own backend
If you send SMS yourself, a test mode with a fixed code is the usual answer. In China it’s often called a universal code (万能验证码). Done carelessly, it is a way into every account. Done carefully:
- Limit it to listed numbers. The fixed code works only for numbers on a short test list, never for any number.
- Turn it on by setting, off by default. Read it from an environment variable that only development and staging set.
- Leave it out of release builds. In a mobile app, keep the code path behind a build flag the release build doesn’t include. Check the release build refuses the code before it ships.
- Check production refuses it. Add a test to your release checks that signs in to production with a test number and the fixed code, and expects it to fail.
What to test in the flow
- A wrong code is refused, and the number of tries is limited.
- An expired code is refused, and asking again sends a new one.
- After a resend, an older code works or doesn’t, as you decided, and the app says which.
- The number is stored in one format (with the country code) whatever the person typed: spaces, a leading 0 or +86.
- Someone who signs up with the same number again is sent to sign-in, not given a second account.
- If the app also asks for an email address, the confirmation email arrives and works. Proxy Mail QA covers that step: create an address, sign up with it, and wait for the code or link.