Mailosaur logo
Mailosaur logo

How to test SMS messages with Mailosaur

Learn how to use Mailosaur phone numbers to create end-to-end tests that cover identity verification, alerting, promotional messages and more.

Available with any of the following plans, except where noted:

Business, Professional and Enterprise

Using the Mailosaur API you can write SMS tests using common frameworks like Cypress, Playwright, Selenium, and Robot Framework, as well as in popular languages, using our SDKs for SMS testing.

How it works
A hashtag icon

Testing SMS messages is as simple as:

  1. Assigning a phone number to one of your servers.
  2. Send SMS messages to that number, just as you normally would.
  3. Use the Mailosaur API to create end-to-end tests using the extracted content.

Testing SMS messages
A hashtag icon

Using Mailosaur’s client libraries you can fetch SMS messages with just a few lines of code.

The code for testing SMS messages is almost identical to testing emails, so you can follow our guides and common test cases to learn more.

const mailosaur = new MailosaurClient('YOUR_API_KEY');
const testStart = new Date(); // Only look for messages after our test began

// Send an SMS message to your test number...

const message = await mailosaur.messages.get('SERVER_ID', {
  sentTo: '1234567890' // YOUR_TEST_NUMBER
}, {
  receivedAfter: testStart

console.log(message.text.body); // "Your order number is 51223"
console.log([0].value); // "51223"

In this section