MailSlurp is a free Javascript plugin for Cypress JS that lets you create real email addresses in tests then send and receive emails from them. This can be really helpful when testing applications or software. Cypress can be used to test user login and app notifications using real email addresses and phone numbers.

YouTube video thumbnail

What is CypressJS

Cypress is a browser testing tool that lets you automate end-to-end testing of your website. You can write test cases in Javascript using the Cypress NPM package. Make assertions about the state of a website or app and Cypress will run the tests in a browser environment for real browser testing.

Cypress has many abilities so try one of these links to get started:

Why test email in Cypress JS?

Many applications today use email. Either for user sign-up, password verification, transactional email, newsletters, and more.

But testing with real email addresses is hard. That's why MailSlurp was created. It lets you generate test email accounts that can send and receive emails. It has an official NPM integration and works well with Cypress async.

See it in action!

Cypress integration test example

We write Cypress tests in NodeJS and configure our browser and capabilities using a config file:

Write your first test

Using the commands we can write tests that make claims about our application and then verify the results. One such test might be to sign up and login to your application and check that a welcome email is sent. The login methods might look like this:

Using email accounts in tests

You can create email inboxes on demand with throwaway email addresses using the MailSlurp cypress plugin or by adding commands ourselves to the Cypress client.

Then we can use the commands in our tests to generate real email accounts and use those to sign up users:

Next steps

Sign up for a free MailSlurp account to start using email in your automated tests today.