Search code examples
emailcachingcypressnodemailer

Nodemailer. createTestAccount and cypress: generate same email address


I created an E2E to test for signups, using Nodemailer with Ethereal.

When the test runs the first time everything ends smoothly, but when I executed it a second time the test, for some reason, breaks.

While investigating the above issue, I noticed that the createTestAccount returns the same email address (unless cypress is restarted).

Here's the function code for createTestAccount: https://github.com/nodemailer/nodemailer/blob/master/lib/nodemailer.js#L58.

  • Is createTestAccount using an internal cache?
  • If yes, is there a way to disable it (besides setting and process.env.ETHEREAL_CACHE to false)?

Solution

  • Based on the current version (6.7.4) of code, it's not possible to disable the cache any other way than setting the env variable ETHEREAL_CACHE to something different than ['true', 'yes', 'y', '1'].

    Aka process.env.ETHEREAL_CACHE needs to be false

    Keep in mind that this is OS level env variable. Not the ones setup in Cypress.
    And the best thing is the great documentation which mentions ETHEREAL_CACHE variable ...