@@ -79,36 +79,26 @@ test('waits for element with custom interval', async () => {
79
79
expect ( mockFn ) . toHaveBeenCalledTimes ( 2 ) ;
80
80
} ) ;
81
81
82
- test ( 'waits for element until it stops throwing using modern fake timers' , async ( ) => {
83
- jest . useFakeTimers ( 'modern' ) ;
84
- const { getByText, queryByText } = render ( < BananaContainer /> ) ;
85
-
86
- fireEvent . press ( getByText ( 'Change freshness!' ) ) ;
87
- expect ( queryByText ( 'Fresh' ) ) . toBeNull ( ) ;
88
-
89
- jest . advanceTimersByTime ( 300 ) ;
90
- const freshBananaText = await waitFor ( ( ) => getByText ( 'Fresh' ) ) ;
91
-
92
- expect ( freshBananaText . props . children ) . toBe ( 'Fresh' ) ;
93
- } ) ;
82
+ test . each ( [ false , true ] ) (
83
+ 'waits for element until it stops throwing using fake timers (legacyFakeTimers = %s)' ,
84
+ async ( legacyFakeTimers ) => {
85
+ jest . useFakeTimers ( { legacyFakeTimers } ) ;
86
+ const { getByText, queryByText } = render ( < BananaContainer /> ) ;
94
87
95
- test ( 'waits for element until it stops throwing using legacy fake timers' , async ( ) => {
96
- jest . useFakeTimers ( 'legacy' ) ;
97
- const { getByText, queryByText } = render ( < BananaContainer /> ) ;
88
+ fireEvent . press ( getByText ( 'Change freshness!' ) ) ;
89
+ expect ( queryByText ( 'Fresh' ) ) . toBeNull ( ) ;
98
90
99
- fireEvent . press ( getByText ( 'Change freshness!' ) ) ;
100
- expect ( queryByText ( 'Fresh' ) ) . toBeNull ( ) ;
101
-
102
- jest . advanceTimersByTime ( 300 ) ;
103
- const freshBananaText = await waitFor ( ( ) => getByText ( 'Fresh' ) ) ;
91
+ jest . advanceTimersByTime ( 300 ) ;
92
+ const freshBananaText = await waitFor ( ( ) => getByText ( 'Fresh' ) ) ;
104
93
105
- expect ( freshBananaText . props . children ) . toBe ( 'Fresh' ) ;
106
- } ) ;
94
+ expect ( freshBananaText . props . children ) . toBe ( 'Fresh' ) ;
95
+ }
96
+ ) ;
107
97
108
- test . each ( [ TimerMode . Legacy , TimerMode . Modern ] ) (
109
- 'waits for assertion until timeout is met with %s fake timers' ,
110
- async ( fakeTimerType ) => {
111
- jest . useFakeTimers ( fakeTimerType ) ;
98
+ test . each ( [ false , true ] ) (
99
+ 'waits for assertion until timeout is met with fake timers (legacyFakeTimers = %s) ' ,
100
+ async ( legacyFakeTimers ) => {
101
+ jest . useFakeTimers ( { legacyFakeTimers } ) ;
112
102
113
103
const mockFn = jest . fn ( ( ) => {
114
104
throw Error ( 'test' ) ;
@@ -124,10 +114,10 @@ test.each([TimerMode.Legacy, TimerMode.Modern])(
124
114
}
125
115
) ;
126
116
127
- test . each ( [ TimerMode . Legacy , TimerMode . Modern ] ) (
128
- 'waits for assertion until timeout is met with %s fake timers' ,
129
- async ( fakeTimerType ) => {
130
- jest . useFakeTimers ( fakeTimerType ) ;
117
+ test . each ( [ false , true ] ) (
118
+ 'waits for assertion until timeout is met with fake timers (legacyFakeTimers = %s) ' ,
119
+ async ( legacyFakeTimers ) => {
120
+ jest . useFakeTimers ( { legacyFakeTimers } ) ;
131
121
132
122
const mockErrorFn = jest . fn ( ( ) => {
133
123
throw Error ( 'test' ) ;
@@ -150,10 +140,10 @@ test.each([TimerMode.Legacy, TimerMode.Modern])(
150
140
}
151
141
) ;
152
142
153
- test . each ( [ TimerMode . Legacy , TimerMode . Legacy ] ) (
154
- 'awaiting something that succeeds before timeout works with %s fake timers' ,
155
- async ( fakeTimerType ) => {
156
- jest . useFakeTimers ( fakeTimerType ) ;
143
+ test . each ( [ false , true ] ) (
144
+ 'awaiting something that succeeds before timeout works with fake timers (legacyFakeTimers = %s) ' ,
145
+ async ( legacyFakeTimers ) => {
146
+ jest . useFakeTimers ( { legacyFakeTimers } ) ;
157
147
158
148
let calls = 0 ;
159
149
const mockFn = jest . fn ( ( ) => {
0 commit comments