@@ -53,15 +53,17 @@ describe('run with real timers', () => {
53
53
const realSetTimeout = global . setTimeout
54
54
55
55
afterEach ( ( ) => {
56
+ // restore timers replaced by jest.useFakeTimers()
56
57
jest . useRealTimers ( )
58
+ // restore setTimeout replaced by assignment
57
59
global . setTimeout = realSetTimeout
58
60
} )
59
61
60
62
test ( 'use real timers when timers are faked with jest.useFakeTimers(legacy)' , ( ) => {
61
63
// legacy timers use mocks and do not rely on a clock instance
62
64
jest . useFakeTimers ( 'legacy' )
63
65
runWithRealTimers ( ( ) => {
64
- expect ( global . setTimeout ) . toEqual ( realSetTimeout )
66
+ expect ( global . setTimeout ) . toBe ( realSetTimeout )
65
67
} )
66
68
expect ( global . setTimeout . _isMockFunction ) . toBe ( true )
67
69
expect ( global . setTimeout . clock ) . toBeUndefined ( )
@@ -71,7 +73,7 @@ describe('run with real timers', () => {
71
73
// modern timers use a clock instance instead of a mock
72
74
jest . useFakeTimers ( 'modern' )
73
75
runWithRealTimers ( ( ) => {
74
- expect ( global . setTimeout ) . toEqual ( realSetTimeout )
76
+ expect ( global . setTimeout ) . toBe ( realSetTimeout )
75
77
} )
76
78
expect ( global . setTimeout . _isMockFunction ) . toBeUndefined ( )
77
79
expect ( global . setTimeout . clock ) . toBeDefined ( )
@@ -86,7 +88,8 @@ describe('run with real timers', () => {
86
88
global . setTimeout = fakedSetTimeout
87
89
88
90
runWithRealTimers ( ( ) => {
89
- expect ( global . setTimeout ) . toEqual ( fakedSetTimeout )
91
+ expect ( global . setTimeout ) . toBe ( fakedSetTimeout )
90
92
} )
93
+ expect ( global . setTimeout ) . toBe ( fakedSetTimeout )
91
94
} )
92
95
} )
0 commit comments