A step-by-step process of implementing email automation

Even with the emergence of tools like Slack and mobile apps with native notifications, email is still a huge part of workplace communications. Here’s a deep dive into why and how to automate email testing, from me, Meaghan, a QA Engineer at Lever!

How email helps you hire better

Top-notch email syncing and tracking is crucial to our product. Imagine you’re a busy recruiter responsible for managing dozens of candidates, looking through hundreds of resumes, all the while the responsibility of filling mission-critical engineering roles rests upon your shoulders. Or, maybe you’re a hiring manager or engineer, trying to keep on top of all the hiring activity and get the best colleagues possible while, oh you know, doing your regular full-time job.

Now imagine, every time you opened up your Applicant Tracking System, all the candidate records are a mess, and you can’t tell who had a last touch point when, why a candidate wasn’t followed up on, or if they should be moving to the next step of the application process.

For your team to have a truly collaborative hiring process that wins candidates, communication via email is critical. Lever makes it easy for all conversations and touch points to be tracked seamlessly within each candidate profile.

Lever’s email editor

How Lever uses email

Our customers trust Lever as a source of truth for all hiring activity and can be assured that all their data is kept up-to-date. Hiring is a team sport, and recruiters, hiring managers, or interviewers alike are constantly exchanging emails with candidates.

Candidate communications include, but are not limited to: scheduling interviews, follow up after interviews, getting status updates and feedback, and sending/accepting offers. All of this communication involves emails being sent back and forth.

To test or not to test, that is not the question

Hiring is hard, and all the pieces have to be working consistently and perfectly in your technology to facilitate this — email being a huge part of it! We want our users to have the best possible experience using Lever.

Because email is integral to the hiring process, we absolutely wanted to cover this functionality with automated tests. That way we save ourselves a whole lot of time from manually testing each email workflow, and we have confidence that email related features are working as expected.

How we tested

Our QA team decided to create automated tests for each workflow that involves email. That happens in various scenarios such as:

  • General Email: Send a candidate an email as a recruiter, respond as the candidate via email, confirm the reply is synced to the candidate profile.
  • Notes: Send a note to a coworker, confirm the email is received by your coworker, and when the coworker responds and reply is synced in profile.
  • Scheduling: Schedule an interview, send the candidate an email to notify. Confirm the candidate and interviewer receive emails.

After deciding what to automate, it was time to get down to business and write some tests. Here is a step-by-step process of how our team did this.

Step 1: Pick the right tools

First, chose the right tools to help us do the job. Our application is built using node, and we figured there must be some node package that we could use. After investigation of many, many node modules — we chose to go with Mail Notifier to read emails and Node Mailer to send emails.

We also considered factors such as number of downloads, how well the package was being maintained, the level of documentation, as well as how it will work with different email providers so we could write tests for both Gmail and Microsoft.

Step 2: Build an email class

After choosing the tools to help with IMAP and SMTP server connections, it was then time to create a class that we could always use for sending and receiving of emails.

This code snippet here shows how we ended up using Mail Notifier to connect to an IMAP server and search for new emails in a particular user’s inbox based on a set of search criteria. The searchForEmail function returns a list of emails found. From that list of emails returned we can make assertions about traits of the email such as the sender, header and body.

This code snippet here handles the sending of email code. First, it connects to an SMTP server and then it sends emails with a transport object. After calling sendEmail function a response object should be returned with the email message and id. The function takes in an email object that has properties about the email such as from, to, subject, body and can include things such as attachments.

Step 3: Write your tests

After having a class that will allow you to send and receive emails, it’s time to put that class to use in your tests! Here are a couple examples of how we wrote our tests and used these searchForEmail and sendEmail functions from our email class.

Example of searching for an email:

Example of sending an email:

What I learned

In starting the email automation project, I was anxious about the level of difficulty and needing to learn a lot more about IMAP and SMTP. But after finding the right tools to approach the challenge, the pieces began to fall into place and I didn’t need to be so intimidated by email testing after all! And now that we’ve invested in creating this reusable email framework, it will save so much time when adding more tests in the future.

I hope that this helps you and your team as you consider doing email automation. Happy testing!

This post was edited with the help of Jennifer Kim, Kate Reading, and Leighton Wallace. Thank you all!

Interested in careers at Lever? Check out our open positions: https://jobs.lever.co/lever

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.