From eade4f5d1387f27227995683aeabd984ab2bcb44 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 6 Nov 2019 12:13:14 +1100 Subject: [PATCH] fix: make sure setTimeout exists on global --- src/helpers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers.js b/src/helpers.js index 1640892a..d12e5e85 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -5,7 +5,9 @@ const globalObj = typeof window === 'undefined' ? global : window // Currently this fn only supports jest timers, but it could support other test runners in the future. function runWithRealTimers(callback) { const usingJestFakeTimers = - globalObj.setTimeout._isMockFunction && typeof jest !== 'undefined' + globalObj.setTimeout && + globalObj.setTimeout._isMockFunction && + typeof jest !== 'undefined' if (usingJestFakeTimers) { jest.useRealTimers()