# Test SMS verification in automated tests

Source: https://jointextkit.com/docs/testing-verification
Index: https://jointextkit.com/llms.txt

An end-to-end test of a sign-in flow needs a code it can type. With a
TextKit test key the code is always `111111`: no phone, no inbox to read,
and no real text sent. It works the same in Playwright, Cypress, Selenium,
or any other test runner, and for coding agents like Claude Code and Codex
running your tests.

## Set up

Give your test environment a test key (`tk_sk_test_`). Your app's code
doesn't change: it makes the same two [Verify](/docs/verify) calls, and
the test key answers like live.

## Codes that force each result

| Code typed | Result |
| --- | --- |
| `111111` | approved |
| `000000` | invalid |
| `222222` | expired |
| `333333` | max attempts |

## Playwright

```ts
import { test, expect } from '@playwright/test';

test('sign in with a phone code', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Phone').fill('+14155550132');
  await page.getByRole('button', { name: 'Send code' }).click();
  await page.getByLabel('Code').fill('111111'); // the sandbox code
  await page.getByRole('button', { name: 'Verify' }).click();
  await expect(page).toHaveURL('/dashboard');
});
```

## Selenium (Python)

```python
from selenium.webdriver.common.by import By

driver.get("https://localhost:3000/login")
driver.find_element(By.NAME, "phone").send_keys("+14155550132")
driver.find_element(By.ID, "send-code").click()
driver.find_element(By.NAME, "code").send_keys("111111")  # the sandbox code
driver.find_element(By.ID, "verify").click()
```

The selectors are your app's own; the code and the test key are the only
TextKit parts.

## Test the edge cases

- **Resend button.** The sandbox has no resend cooldown, so you can click
  it as often as you like. To test the cooldown itself, send to
  `+15005550003`: it always answers `429` with `retry_after`.
- **Blocked numbers.** `+15005550021` to `+15005550027` each answer
  `403 verification_blocked` with one reason, like a live key would. See
  the [table in Verify](/docs/verify#shield).
- **Email codes.** Any address works, `example.com` included, and the
  code is `111111`. `cooldown@textkit.test` always returns the cooldown.

## Keep live keys out of CI

A test key never sends a real text and never bills. A live key in CI would
text real numbers and charge for each successful check. Set the test key in
your CI secrets and the live key only in production.

More on test mode: [Sandbox & test numbers](/docs/sandbox).
