From 2f229191a3e7ec25e587628676248b89ea2cd61c Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 5 Oct 2022 11:27:15 -0400 Subject: [PATCH] fix: make Jest fake timers check more robust to other libs that overwrite time functions Fix #12514 --- lib/helpers/printJestWarning.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers/printJestWarning.js b/lib/helpers/printJestWarning.js index 7cef461adb7..2d9330b52c6 100644 --- a/lib/helpers/printJestWarning.js +++ b/lib/helpers/printJestWarning.js @@ -9,7 +9,7 @@ if (typeof jest !== 'undefined' && typeof window !== 'undefined') { 'https://mongoosejs.com/docs/jest.html'); } -if (typeof jest !== 'undefined' && process.nextTick.toString().indexOf('nextTick') === -1) { +if (typeof jest !== 'undefined' && setTimeout.clock != null && typeof setTimeout.clock.Date === 'function') { utils.warn('Mongoose: looks like you\'re trying to test a Mongoose app ' + 'with Jest\'s mock timers enabled. Please make sure you read ' + 'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +