Skip to content

fix(tests): make useStoreRehydrated suspense test deterministic#1032

Merged
ctrlplusb merged 1 commit intov7-devfrom
1031-fix-rehydrated-test-flake
May 4, 2026
Merged

fix(tests): make useStoreRehydrated suspense test deterministic#1032
ctrlplusb merged 1 commit intov7-devfrom
1031-fix-rehydrated-test-flake

Conversation

@ctrlplusb
Copy link
Copy Markdown
Owner

Summary

The useStoreRehydrated test in `tests/persist.test.js` is flaky under
coverage instrumentation in CI — it failed on the v7 release PR (#1031).

The test relied on a setTimeout-based async memory storage (18ms) to keep
the rehydration promise pending while asserting the Suspense fallback.
Under coverage instrumentation the timer can fire inside the surrounding
`act()` block, so React unsuspends and the `Loading...` assertion fails
with `expected null not to be null`.

Changes

  • `tests/persist.test.js` — replace the timer-based async storage with a
    manually-controlled deferred promise. The rehydration gate is held until
    the test explicitly releases it, removing the timing race.

The test relied on a setTimeout-based async memory storage (18ms wait)
to keep the rehydration promise pending while asserting the Suspense
fallback. Under coverage instrumentation in CI the timer could fire
inside the surrounding act() block, so React unsuspended before the
Loading assertion ran.

Switches to a manually-controlled deferred promise so the rehydration
gate is held until the test explicitly releases it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
easy-peasy Building Building Preview, Comment May 4, 2026 3:46am
easy-peasy-v6 Building Building Preview, Comment May 4, 2026 3:46am

@ctrlplusb ctrlplusb merged commit 638af90 into v7-dev May 4, 2026
1 of 4 checks passed
@ctrlplusb ctrlplusb deleted the 1031-fix-rehydrated-test-flake branch May 4, 2026 03:46
ctrlplusb added a commit that referenced this pull request May 4, 2026
The test relied on a setTimeout-based async memory storage (18ms wait)
to keep the rehydration promise pending while asserting the Suspense
fallback. Under coverage instrumentation in CI the timer could fire
inside the surrounding act() block, so React unsuspended before the
Loading assertion ran.

Switches to a manually-controlled deferred promise so the rehydration
gate is held until the test explicitly releases it.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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