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
This commit is contained in:
Sanne de Vries 2023-03-17 18:12:53 +01:00
parent a6654b5e6c
commit 1b0adcf4ab

View File

@ -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 () {