Skip to content

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

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

antonisetkowicz wants to merge 2 commits 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)

antonisetkowicz and others added 2 commits June 20, 2026 22:26
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)

This branch has not been deployed

No deployments
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.

2 participants