Frameworks and toolsPlaywrightQuickstart

Mailosaur and Playwright - Quickstart guide

Get Mailosaur up and running within your Playwright project in a few steps

What you'll need

  • A Mailosaur account or free trial account.
  • An API key generated in your account.
  • Knowledge of how to send emails (or SMS) into your account.

Express: Generate with a sample project

With npm installed, get started by generating a basic starter project for Playwright via the command line:

npm create mailosaur@latest

This gives you a simple Playwright project with Mailosaur pre-configured, along with some basic tests. You can also see sample code on GitHub.

Integrate into an existing Playwright project

With an existing Playwright project (or one you've just created), this is how to install and configure Mailosaur's API client library:

Install the API client

  1. Install the Mailosaur Node.js library:
npm install mailosaur
  1. Import the Mailosaur client into your test code:
const MailosaurClient = require("mailosaur");

// Find your API key at https://mailosaur.com/app/keys
const mailosaur = new MailosaurClient("API_KEY");

Make your first API call

// Make a simple API call to find the name of your inbox
const result = await mailosaur.servers.list();
console.log(`Inbox name is ${result.items[0].name}`);

Start testing

With a project connected to the Mailosaur API, you can start creating tests: