Skip to content

test: fix flaky 'limit reset per Local storage' test#451

Open
antonisetkowicz wants to merge 1 commit into
fastify:mainfrom
antonisetkowicz:fix/flaky-limit-reset-test
Open

test: fix flaky 'limit reset per Local storage' test#451
antonisetkowicz wants to merge 1 commit into
fastify:mainfrom
antonisetkowicz:fix/flaky-limit-reset-test

Conversation

@antonisetkowicz

Copy link
Copy Markdown

Summary

The limit reset per Local storage test was marked as skip: true with a TODO comment asking to rewrite it using fake timers instead of setTimeout.

This PR:

  • Replaces setTimeout-based timing with node:test built-in mock.timers (already used by other tests in this file)
  • Uses sequential await fastify.inject() + clock.tick() instead of parallel setTimeout callbacks
  • Removes the { skip: true } flag so the test runs in CI again

Before

  • Test was skipped due to flakiness from real-time setTimeout delays
  • 38 tests ran, 1 skipped

After

  • Test uses deterministic fake timers — no flakiness
  • 39 tests pass, 0 skipped

Checklist

  • node --test test/route-rate-limit.test.js — 39 pass, 0 fail
  • node --test test/*.test.js — 101 pass, 0 fail
  • No new dependencies (uses built-in node:test mock timers)

Replace setTimeout-based timing with node:test mock.timers for
deterministic behavior. The test was skipped since it relied on
real-time delays which made it flaky in CI.

Closes #698 (inline TODO)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant