Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
How to generate unique random emails with nodemailer

I would like to use nodemailer in a few tests to be able to pragmatically test the contents of an email that is sent. So far, its working great but there is one issue I haven't been able to solve.

I am using the createTestAccount from the Javascript nodemailer, and notice that it often returns me the same test email (I think it uses the same email for a period of time?)

How can I use this to always generate different emails?

I have a condition where I my code fails if the email isn't unique across tests.


As an example, a flow I am testing is:

  1. [behind the scenes a user is created in the database]
  2. User goes to sign in page
  3. User enters email and is asked to enter one time password
  4. User signs into email and gets code
  5. User enters code into website and is successfully signed in

The email with the one time password is sent via an external service so I can't mock it.

For each of my tests there are different configurations so I need a unique user I create in the background for each test. My tests also change the information about the user (in the database). I am also running these tests in parallel so using the same user will result in tests being influenced by other tests.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After looking the source code of nodemailer I found there is a cache you can disabled by ETHEREAL_CACHE=false. This generates new emails every time.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda