From 507a58c9c52512ba206348991a1f1c4185becf97 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 26 Oct 2021 14:31:56 +0100 Subject: [PATCH] Add timeout to node mailer, lower than jest default --- packages/worker/src/api/routes/tests/realEmail.spec.js | 3 --- .../worker/src/api/routes/tests/utilities/TestConfiguration.js | 1 + packages/worker/src/utilities/email.js | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/worker/src/api/routes/tests/realEmail.spec.js b/packages/worker/src/api/routes/tests/realEmail.spec.js index 54238e9270..a2474bb97a 100644 --- a/packages/worker/src/api/routes/tests/realEmail.spec.js +++ b/packages/worker/src/api/routes/tests/realEmail.spec.js @@ -3,9 +3,6 @@ const { EmailTemplatePurpose } = require("../../../constants") const nodemailer = require("nodemailer") const fetch = require("node-fetch") -// need a longer timeout for getting these -jest.setTimeout(30000) - describe("/api/global/email", () => { let request = setup.getRequest() let config = setup.getConfig() diff --git a/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js b/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js index 9638e2a2a7..c40b6d8dec 100644 --- a/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js +++ b/packages/worker/src/api/routes/tests/utilities/TestConfiguration.js @@ -234,6 +234,7 @@ class TestConfiguration { user: "don.bahringer@ethereal.email", pass: "yCKSH8rWyUPbnhGYk9", }, + connectionTimeout: 1000, // must be less than the jest default of 5000 }, }, null, diff --git a/packages/worker/src/utilities/email.js b/packages/worker/src/utilities/email.js index 25a2d35200..f11ec90a27 100644 --- a/packages/worker/src/utilities/email.js +++ b/packages/worker/src/utilities/email.js @@ -35,6 +35,9 @@ function createSMTPTransport(config) { options.tls = { rejectUnauthorized: false, } + if (config.connectionTimeout) { + options.connectionTimeout = config.connectionTimeout + } } else { options = { port: 587,