Skip to content

kostyrko/cypress-email-example

 
 

Repository files navigation

cypress-email-example

ci status badges status renovate-app badge cypress version cypress-email-example

Sending emails using nodemailer, receive the using smtp-tester and testing the received email using Cypress.

The HTML email test

See cypress/integration/spec.js

Read the blog post Testing HTML Emails using Cypress and watch this video where I explain the entire testing process.

Install and run

$ npm install
$ npm start
# from another terminal
$ npx cypress open
# click the spec.js

The application

The application shows the registration page pages/index.js where the user can fill the email and click the submit button. The page makes an Ajax request to the pages/api/register.js handler which sends an email. The email has the confirmation code the user is expected to enter on the confirmation page pages/confirm.js.

Email server

The emails are sent using nodemailer, see emailer.js. During tests the SMTP server is running inside cypress/plugins/index.js process.

Cypress tests

The tests run on GitHub Actions, see the .github/workflows/ci.yml workflow. The results are recorded on Cypress Dashboard.

About

Testing HTML emails using Cypress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 61.7%
  • HTML 38.3%