Send With Confidence
Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.
Time to read: 7 minutes
We recently passed a huge milestone of over 3 trillion emails sent.In our testing environments, we send our emails to test email inboxes in self-hosted Squirrelmail servers to avoid sending out test emails to actual email inbox service providers such as Gmail. Many important flows require the user to check their email, click on an actionable link, redirect back to the web application, and then continue onward at some download or verification success page.
cy.task()
to run arbitrary code we define in a Node server to assist us with dealing with emails. Also, if the later code snippets with TypeScript are a bit confusing, it may clear things up to see our blog post about how we typed our Cypress tests. You can still modify the code in your own Cypress tests by removing the type definitions and sticking to JavaScript-only syntax.
cy.task()
plugins to:
squirrelmail.ts
that we would later import in our plugins/index.ts
for our cy.task()
function definitions.
cy.request()
, follow the redirect link back to the web app we control and own on the one superdomain, and proceed with verifying success states on the page we redirected to.
cy.visit(linkPath)
to redirect back to your app. In the case of Twilio SendGrid links, the links may look like “...sendgrid.net?...” if you have link tracking on for your emails or “brandedlink.com” if you have link branding on. That is why we would need to make an HTTP request and extract the redirect path to do a cy.visit(redirectPath)
because the immediate “href” of the links do not match up with our web app.
cy.task()
plugin functions we implemented to do more read and delete actions with matching emails in our inboxes. We created these functions to properly reset the user’s email inbox state before we trigger these email flows in the web pages, wait for the emails to arrive in the inbox, and finally follow the links back to their success states. We summarize the key steps for your Cypress tests below:
cy.task(“teardownMatchingEmails”)
.cy.task(“awaitEmailInSquirrelmailInbox”)
.cy.task(“squirrelmailSearchBySubject”)
.cy.request(“link”)
and follow the redirect response back to the web app or visit the path if the links already match up with your superdomain with cy.visit(“emailLinkToWebApp”)
.Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.