100MB FREEResidential proxiesClaim
NumberOTP

SMS OTP Testing: Test Numbers, Emulators and Real SMS

SMS OTP testing without a real phone: Firebase, Supabase and Clerk test numbers, Twilio magic numbers, AWS simulators, and when you need a real number.

DS
June 6, 202611 min read

For SMS OTP testing, most of your tests don't need a real phone number: mock the SMS sender in unit tests, use your auth platform's test numbers with fixed codes (Firebase, Supabase, Clerk and Google Identity Platform all have them), and use your SMS API's test credentials or simulator numbers to check sending. You need a real number only for the end-to-end check that a code actually leaves your system, crosses a carrier and arrives. This guide covers each option with the exact limits from the vendors' own docs (checked 1 December 2026), when each one stops being enough, and a working real-number test. If you build with Firebase, our Firebase phone auth test numbers guide goes deeper on that stack.

Which SMS OTP test method should you use?

Use the cheapest method that still exercises the thing you are testing. Each layer below catches a different class of bug, and a good suite uses several.

MethodReal SMS sent?What it provesWhat it missesBest for
Mock the SMS senderNoYour code calls the sender with the right number and messageEverything outside your codeUnit tests
Auth platform test numbers (fixed code)NoYour sign-in UI and verify logic accept a codeDelivery, real code generation timingUI and integration tests, app review accounts
Local emulators (Firebase Auth emulator, Android emulator)NoFull client flow offline; SMS-reading code on AndroidCarrier deliveryLocal development, CI without network
SMS API test credentials and simulator numbersNo (stays inside the API)Your API requests are valid; error handling for known failuresDelivery to a handsetIntegration tests of the sending path
Staging bypass code (e.g. 000000)NoManual QA speedEverything about OTP; risky if it leaksManual staging tests only
Real receiving numberYesThe code is generated, sent, delivered and acceptedNothing in the flow, but costs money and timeEnd-to-end and release checks

1. Mock the SMS sender in unit tests

Mocking replaces your SMS-sending function with a fake so unit tests run offline in milliseconds. It tells you your code asked for an SMS with the right arguments, and nothing about whether one could be delivered.

jest.mock('./smsService', () => ({
  sendOtp: jest.fn().mockResolvedValue({ messageId: 'mock-123', status: 'sent' }),
}));

test('registration sends an OTP', async () => {
  await registerUser({ phone: '+12025550123' });
  expect(smsService.sendOtp).toHaveBeenCalledWith('+12025550123', expect.any(String));
});

Also mock the failure cases (provider timeout, invalid number, rate limit) and assert what your user sees. For numbers in fixtures, use ranges reserved for fiction (such as 555-01xx in North America) rather than real-looking digits.

2. Test phone numbers with fixed codes in auth platforms

Most hosted auth platforms let you register test phone numbers that accept a fixed code and send no SMS. They are the fastest way to test sign-in screens, and the right way to give app-store reviewers a login.

  • Firebase Authentication: up to 10 fictional numbers with codes you choose; no SMS is sent, they don't consume quota and aren't throttled. On web, appVerificationDisabledForTesting skips reCAPTCHA but works only with fictional numbers (Firebase phone auth docs).
  • Google Cloud Identity Platform: up to 10 test numbers in E.164 with a six-digit code; no SMS, no quota use, and Google advises hard-to-guess numbers rotated regularly (Identity Platform docs).
  • Supabase Auth: number=OTP pairs with a required "valid until" date; no SMS is sent, but phone MFA always sends a real SMS, and an SMS provider must still be configured. Supabase warns that anyone who knows a test number and code can sign in as that user (Supabase testing guide).
  • Clerk: numbers from +1 (XXX) 555-0100 to 555-0199 verify with code 424242 and send no SMS; test mode is on by default in development instances (Clerk docs).

The catch: a fixed code never expires the way a real one does, so these tests can't catch expiry, resend or rate-limit bugs. And a test number left active in production is a working login for anyone who finds it, so put an expiry on it and check for it in your release checklist.

3. Emulators: Firebase Auth emulator and Android emulator SMS

Emulators run the whole flow locally and hand you the code without any carrier involved.

  • Firebase Auth emulator: sends no SMS; it prints the code to the terminal running the emulator and exposes it through a REST endpoint for scripted tests. You can't predefine fixed-code test numbers in it, and reCAPTCHA is disabled while connected (Firebase emulator docs).
  • Android emulator: to test code that reads incoming SMS (autofill, SMS Retriever), inject a message from the console with adb emu sms send 4085555555 "Your code is 123456". The emulator passes it to the device's SMS app as an incoming text (emulator console reference).

4. SMS API test credentials and simulator numbers

SMS APIs offer test modes that accept real API requests but never send a message, so you can check request format and error handling without cost.

Twilio test credentials and magic numbers

With Twilio's test credentials, requests aren't charged and don't connect to real phones; only buying numbers, sending SMS, making calls and Lookup are supported, and status callbacks aren't triggered (Twilio test credentials). Magic numbers simulate specific outcomes:

NumberUsed asSimulates
+15005550006FromValid sender; message accepted
+15005550001ToInvalid number (error 21211)
+15005550002ToCan't route to number (21612)
+15005550003ToNo international permission (21408)
+15005550004ToNumber blocked for your account (21610)
+15005550009ToNumber can't receive SMS (21614)

These are ideal for asserting that your app shows a sensible error for each failure. They tell you nothing about whether a code reaches a handset.

AWS End User Messaging SMS simulator numbers

AWS provides simulator numbers that keep messages inside AWS instead of sending them over the carrier network, while still producing realistic event records. Destination simulator numbers exist for dozens of countries, most with one number that returns success events and one that returns failure events; origination simulator numbers are US-only and can only send to destination simulators in the same country (AWS simulator numbers).

5. Staging bypass codes: use with care

A staging-only rule that accepts a fixed code such as 000000 for any number makes manual QA fast, but it is the riskiest option. If the flag ever reaches production, anyone can log in as anyone.

  • Gate it behind an environment variable that defaults to off, and fail the build if it is set in a production config.
  • Limit it to an allow-list of test numbers instead of "any number".
  • Log every use so you notice if it fires where it shouldn't.

6. When you need a real phone number

You need a real receiving number when the question is "does a real code reach a real phone?": before a release, after changing SMS vendor or sender ID, when launching in a new country, and when debugging user reports that codes don't arrive. Everything above stops at your API boundary; carrier filtering, sender-ID rules and message formatting only show up on real delivery.

A practitioner's point worth keeping in mind from a Ministry of Testing discussion: once you've shown the message left your system, carrier delivery is largely outside your control, so a few real-number checks per release usually beat running every test against real SMS.

Your options for real numbers, in rough order of convenience:

  • A virtual number you control through an API, bought per test and released afterwards. Good for CI because tests can run in parallel from any machine.
  • A rented number for a test cycle of days or weeks, so testers don't need a new number per code.
  • A dedicated test SIM in a device. Works, but only one test can use it at a time and someone has to read the phone.

Avoid free public "receive SMS online" pages: anyone can read the codes, and the numbers are shared by many users.

Example: an end-to-end OTP test with a real number

This Python test uses the official numberotp SDK (pip install numberotp, key in NOTP_API_KEY). It buys a number for the generic "any other" service (ot) in the US (country 187), with a price ceiling, triggers your app, waits up to three minutes for the code, and cancels the number if anything fails. Your app's endpoints are placeholders.

import requests
from numberotp import NumberOTP, WaitTimeoutError

notp = NumberOTP()  # reads NOTP_API_KEY
APP = "https://staging.your-app.example"

def test_signup_with_real_sms():
    n = notp.activations.create(service="ot", country="187", max_price=1.0)["data"]
    phone, act_id = n["phoneNumber"], n["id"]
    done = False
    try:
        requests.post(f"{APP}/api/register", json={"phone": phone}, timeout=30)
        act = notp.activations.wait_for_code(act_id, timeout=180)
        assert act["otp"], "SMS arrived but no code was found in it"

        r = requests.post(f"{APP}/api/verify", json={"phone": phone, "otp": act["otp"]}, timeout=30)
        assert r.json()["verified"] is True
        notp.activations.finish(act_id)
        done = True
    except WaitTimeoutError:
        raise AssertionError("No SMS within 3 minutes: check your sender's logs for this number")
    finally:
        if not done:
            try:
                notp.activations.cancel(act_id)
            except Exception:
                pass  # if cancel is refused, the number expires unused and is refunded

Notes on that code: the SDK returns the number as digits with the country code and no leading +, so normalise it to E.164 if your form expects one (our E.164 format errors guide lists the usual mismatches). A one-time number stays active for up to 20 minutes, and if no SMS arrives the full price goes back to the balance automatically. For the TypeScript version as a Playwright fixture, see SMS OTP codes in Playwright tests; to have codes pushed to you instead of waiting, see an OTP webhook receiver in Node.js.

Common mistakes in OTP test suites

Most flaky OTP tests come from timing and state, not from SMS itself.

  • Timeouts in the wrong order. Your code wait must be shorter than the test timeout, which must be shorter than the number's life, or a slow SMS turns into a confusing timeout instead of a clear failure.
  • Reusing one number across tests. An old code arrives late and the test submits it. Use a fresh number per test, or match the code to the request.
  • Only testing the happy path. Assert that wrong, expired and reused codes are rejected and that resend invalidates the previous code.
  • Badly formatted numbers. Normalise to E.164 before the number reaches your SMS API.
  • Forgetting captchas. If sign-up has a captcha, use the vendor's test keys in staging; see testing sign-up with captcha and SMS OTP.
  • Leaving test numbers live. Fixed-code test numbers and bypass flags in production are working logins.

Frequently Asked Questions

How do I test OTP SMS without a real phone number?

Mock your SMS sender in unit tests, register test phone numbers with fixed codes in your auth platform (Firebase, Supabase, Clerk and Google Identity Platform support them), and use your SMS API's test credentials or simulator numbers to check sending. None of these send a real SMS. Add a small number of real-number checks before releases to confirm codes are actually delivered.

Is there a test number for sending SMS?

Yes. Twilio's test credentials come with magic numbers: +15005550006 as the sender simulates a valid message, and numbers such as +15005550001 or +15005550009 as the recipient simulate invalid or non-SMS-capable numbers. AWS End User Messaging SMS has simulator numbers that keep messages inside AWS and return success or failure events. None of them deliver to a handset.

Do Firebase test phone numbers receive real SMS?

No. Firebase lets you add up to 10 fictional phone numbers with codes you choose, and no SMS is sent to them; they also don't use your quota and aren't throttled. That makes them good for UI tests and app review accounts, but they can't test code expiry, delivery or resend behaviour, which need real codes and real messages.

When do I need a real phone number for OTP testing?

Use a real receiving number when you need to prove a code actually reaches a phone: before a release, after changing SMS vendor or sender ID, when launching in a new country, and when users report codes not arriving. Test numbers and simulators stop at the API, so carrier filtering and formatting problems only show up with real delivery.

Can I use free receive-SMS websites for testing?

It is not a good idea. Codes on free public pages are visible to anyone, the numbers are shared by many users, and you can't control them from a test runner. For automated tests, use a number you control through an API or a rented number, and keep any codes and test accounts private.

Run your first real-number test

Read the NumberOTP API docs for the SDKs, CLI and webhooks, check live US numbers for your test country, and create an account; eligible new accounts get a $0.10 trial credit to try the flow.

Frequently Asked Questions

How do I test OTP SMS without a real phone number?+

Mock your SMS sender in unit tests, register test phone numbers with fixed codes in your auth platform (Firebase, Supabase, Clerk and Google Identity Platform support them), and use your SMS API's test credentials or simulator numbers to check sending. None of these send a real SMS. Add a small number of real-number checks before releases to confirm codes are actually delivered.

Is there a test number for sending SMS?+

Yes. Twilio's test credentials come with magic numbers: +15005550006 as the sender simulates a valid message, and numbers such as +15005550001 or +15005550009 as the recipient simulate invalid or non-SMS-capable numbers. AWS End User Messaging SMS has simulator numbers that keep messages inside AWS and return success or failure events. None of them deliver to a handset.

Do Firebase test phone numbers receive real SMS?+

No. Firebase lets you add up to 10 fictional phone numbers with codes you choose, and no SMS is sent to them; they also don't use your quota and aren't throttled. That makes them good for UI tests and app review accounts, but they can't test code expiry, delivery or resend behaviour, which need real codes and real messages.

When do I need a real phone number for OTP testing?+

Use a real receiving number when you need to prove a code actually reaches a phone: before a release, after changing SMS vendor or sender ID, when launching in a new country, and when users report codes not arriving. Test numbers and simulators stop at the API, so carrier filtering and formatting problems only show up with real delivery.

Can I use free receive-SMS websites for testing?+

It is not a good idea. Codes on free public pages are visible to anyone, the numbers are shared by many users, and you can't control them from a test runner. For automated tests, use a number you control through an API or a rented number, and keep any codes and test accounts private.

Need a number right now? Get $0.10 in free credits — no card required.

Sign up free →

Written by

DS

Founder, NumberOTP

Dishant Singh founded NumberOTP and has spent years working in the virtual number and SMS verification market. He builds the platform, the API and the developer tools, and writes about how verification works behind the scenes, integrating OTP flows and choosing a number service.

More from Dishant →

Get your first OTP number free

$0.10 in credits on signup. No card required. Works for 800+ platforms.

Get started free →