Skip to content

Commit cbceb60

Browse files
committed
Fix flaky timing tests on Windows CI
Increase timing margins for Windows CI environment: - Cache TTL test: 100ms TTL → 200ms, wait times 50ms/75ms → 100ms/120ms - HTTP timeout test: 500ms timeout → 2000ms (100ms /slow endpoint)
1 parent 681ca46 commit cbceb60

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/cache-with-ttl.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,16 @@ describe('cache-with-ttl', () => {
329329

330330
it('should refresh TTL on set', async () => {
331331
const refreshCache = createTtlCache({
332-
ttl: 100,
332+
ttl: 200,
333333
prefix: 'refresh-cache',
334334
})
335335

336336
await refreshCache.set('key', 'value1')
337-
await new Promise(resolve => setTimeout(resolve, 50))
337+
await new Promise(resolve => setTimeout(resolve, 100))
338338
await refreshCache.set('key', 'value2') // Refresh TTL
339339

340-
await new Promise(resolve => setTimeout(resolve, 75))
341-
// Should still be cached (50 + 75 = 125ms, but TTL refreshed at 50ms)
340+
await new Promise(resolve => setTimeout(resolve, 120))
341+
// Should still be cached (100 + 120 = 220ms, but TTL refreshed at 100ms)
342342
expect(await refreshCache.get<string>('key')).toBe('value2')
343343

344344
await refreshCache.clear()

test/http-request.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ describe('http-request', () => {
329329

330330
it('should complete before timeout', async () => {
331331
const response = await httpRequest(`${httpBaseUrl}/slow`, {
332-
timeout: 500,
332+
timeout: 2000,
333333
})
334334
expect(response.text()).toBe('Slow response')
335335
})

0 commit comments

Comments
 (0)