Videos
Check out our tutorial video series.
Efficient end-to-end app testing with Playwright and MailSlurp: Learn how to test emails, login, and app functionality all at once!
Playwright is a powerful end-to-end integration testing framework created by Microsoft with support for multiple browsers and frameworks. It's a modern alternative to browser testing frameworks like Cypress and Selenium. Add MailSlurp to your test suite to test email login and verification with Playwright for full application testing using disposable email accounts.
In this example we will test a demo application called the Playground that allows user sign up with an email address and password. Upon signing up the user is sent a verification code that must be extracted from the email and entered into the confirm user form.
The easiest way to get started is to use the methods in a new folder:
This will create a and an example test suite. The config for this example is as follows:
Next we should install MailSlurp's free email library via NPM:
Create a free account and copy your API Key from the dashboard. We will need this for the next step.
Let's write a test that signs up for an account on our test application called playground. We will create a new email address using MailSlurp, fill the login form and then receive an email verification code. We can extract the code from the disposable email account using MailSlurp and then submit the code to verify our address.
Playwright tests use a Jest-like structure and a page object to select elements on a page and wait for conditions.
The most import part of this test is using the disposable email account we created to receive a verification email and extract the code using a regex.
We can then enter the code into the verification form input and verify our user account.
To run the tests we can create a like so:
Then run the tests with . A successful login will show this friendly dog and a welcome message:
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.