@@ -153,21 +153,23 @@ export const testClearIntervalAcceptsBothTypes = {
153153} ;
154154
155155// Test that the refresh() method works correctly
156+ // NOTE: Using larger timing margins (200ms/100ms instead of 50ms/30ms) because
157+ // Windows has ~15.6ms timer resolution and significant jitter under load.
156158export const testTimeoutRefresh = {
157159 async test ( ) {
158160 let callCount = 0 ;
159161
160- // Create a timeout that would fire in 50ms
162+ // Create a timeout that would fire in 200ms
161163 const timeout = globalThis . setTimeout ( ( ) => {
162164 callCount ++ ;
163- } , 50 ) ;
165+ } , 200 ) ;
164166
165- // Wait 30ms , then refresh (reset the timer)
166- await new Promise ( ( r ) => globalThis . setTimeout ( r , 30 ) ) ;
167+ // Wait 100ms , then refresh (reset the timer)
168+ await new Promise ( ( r ) => globalThis . setTimeout ( r , 100 ) ) ;
167169 timeout . refresh ( ) ;
168170
169- // Wait another 30ms (total 60ms from start, but only 30ms from refresh)
170- await new Promise ( ( r ) => globalThis . setTimeout ( r , 30 ) ) ;
171+ // Wait another 100ms (total 200ms from start, but only 100ms from refresh)
172+ await new Promise ( ( r ) => globalThis . setTimeout ( r , 100 ) ) ;
171173
172174 // The callback shouldn't have fired yet since we refreshed
173175 strictEqual (
@@ -176,8 +178,8 @@ export const testTimeoutRefresh = {
176178 'Callback should not have fired yet after refresh'
177179 ) ;
178180
179- // Wait another 30ms for the refreshed timer to fire
180- await new Promise ( ( r ) => globalThis . setTimeout ( r , 30 ) ) ;
181+ // Wait another 150ms for the refreshed timer to fire (with margin)
182+ await new Promise ( ( r ) => globalThis . setTimeout ( r , 150 ) ) ;
181183
182184 // Now it should have fired
183185 strictEqual ( callCount , 1 , 'Callback should have fired once' ) ;
0 commit comments