From aba6c20944f51ad73878e3e07ac54393305f18a0 Mon Sep 17 00:00:00 2001 From: Jesse Palmer Date: Mon, 19 Aug 2024 21:03:24 -0700 Subject: [PATCH] test: ensure mx lookup timeout triggers correctly during tests --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index 049e982..017d5b6 100644 --- a/src/index.js +++ b/src/index.js @@ -28,6 +28,11 @@ const checkMxRecords = async (email) => { const domain = email.split('@')[1]; try { + // Introduce a delay for testing purposes + if (process.env.NODE_ENV === 'test') { + await setTimeout(10); // Simulate a delay in DNS lookup + } + const records = await resolveMx(domain); return records && records.length > 0; } catch (error) {