@@ -14,6 +14,7 @@ import type {Global} from 'types/Global';
1414import type ModuleMocker from 'jest-mock' ;
1515
1616const { formatStackTrace} = require ( './messages' ) ;
17+ const setGlobal = require ( './setGlobal' ) ;
1718
1819type Callback = ( ...args : any ) => void ;
1920
@@ -287,25 +288,29 @@ class FakeTimers {
287288 }
288289
289290 useRealTimers ( ) {
290- this . _global . clearImmediate = this . _timerAPIs . clearImmediate ;
291- this . _global . clearInterval = this . _timerAPIs . clearInterval ;
292- this . _global . clearTimeout = this . _timerAPIs . clearTimeout ;
293- this . _global . process . nextTick = this . _timerAPIs . nextTick ;
294- this . _global . setImmediate = this . _timerAPIs . setImmediate ;
295- this . _global . setInterval = this . _timerAPIs . setInterval ;
296- this . _global . setTimeout = this . _timerAPIs . setTimeout ;
291+ const global = this . _global ;
292+ setGlobal ( global , 'clearImmediate' , this . _timerAPIs . clearImmediate ) ;
293+ setGlobal ( global , 'clearInterval' , this . _timerAPIs . clearInterval ) ;
294+ setGlobal ( global , 'clearTimeout' , this . _timerAPIs . clearTimeout ) ;
295+ setGlobal ( global , 'setImmediate' , this . _timerAPIs . setImmediate ) ;
296+ setGlobal ( global , 'setInterval' , this . _timerAPIs . setInterval ) ;
297+ setGlobal ( global , 'setTimeout' , this . _timerAPIs . setTimeout ) ;
298+
299+ global . process . nextTick = this . _timerAPIs . nextTick ;
297300 }
298301
299302 useFakeTimers ( ) {
300303 this . _createMocks ( ) ;
301304
302- this . _global . clearImmediate = this . _fakeTimerAPIs . clearImmediate ;
303- this . _global . clearInterval = this . _fakeTimerAPIs . clearInterval ;
304- this . _global . clearTimeout = this . _fakeTimerAPIs . clearTimeout ;
305- this . _global . process . nextTick = this . _fakeTimerAPIs . nextTick ;
306- this . _global . setImmediate = this . _fakeTimerAPIs . setImmediate ;
307- this . _global . setInterval = this . _fakeTimerAPIs . setInterval ;
308- this . _global . setTimeout = this . _fakeTimerAPIs . setTimeout ;
305+ const global = this . _global ;
306+ setGlobal ( global , 'clearImmediate' , this . _fakeTimerAPIs . clearImmediate ) ;
307+ setGlobal ( global , 'clearInterval' , this . _fakeTimerAPIs . clearInterval ) ;
308+ setGlobal ( global , 'clearTimeout' , this . _fakeTimerAPIs . clearTimeout ) ;
309+ setGlobal ( global , 'setImmediate' , this . _fakeTimerAPIs . setImmediate ) ;
310+ setGlobal ( global , 'setInterval' , this . _fakeTimerAPIs . setInterval ) ;
311+ setGlobal ( global , 'setTimeout' , this . _fakeTimerAPIs . setTimeout ) ;
312+
313+ global . process . nextTick = this . _fakeTimerAPIs . nextTick ;
309314 }
310315
311316 _checkFakeTimers ( ) {
0 commit comments