From 1b0adcf4ab43ba80e55e60a1d71f60bf374f9bfb Mon Sep 17 00:00:00 2001 From: Sanne de Vries Date: Fri, 17 Mar 2023 18:12:53 +0100 Subject: [PATCH] Fixed missing stub for DNS in GhostMailer Direct tests - without this, Node will try and resolve the domain name but local DNS resolvers can take a while to timeout, which causes the tests to timeout - `nodemailer-direct-transport` calls `dns.resolveMx`, so if we stub that function and return an empty array, we can avoid any real DNS lookups --- ghost/core/test/unit/server/services/mail/GhostMailer.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ghost/core/test/unit/server/services/mail/GhostMailer.test.js b/ghost/core/test/unit/server/services/mail/GhostMailer.test.js index 38d9a832ad..627a217fca 100644 --- a/ghost/core/test/unit/server/services/mail/GhostMailer.test.js +++ b/ghost/core/test/unit/server/services/mail/GhostMailer.test.js @@ -1,3 +1,4 @@ +const dns = require('dns'); const should = require('should'); const sinon = require('sinon'); const mail = require('../../../../../core/server/services/mail'); @@ -115,10 +116,13 @@ describe('Mail: Ghostmailer', function () { configUtils.set({mail: {}}); mailer = new mail.GhostMailer(); + + sinon.stub(dns, 'resolveMx').yields(null, []); }); afterEach(function () { mailer = null; + sinon.restore(); }); it('return correct failure message for domain doesn\'t exist', async function () {