Skip to content

Conversation

jasonyuezhang
Copy link
Owner

These tests have been flaky in CI for quite some time, and I got some failures again today:

I think the issue is that awaiting the network request does not guarantee that the component has re-rendered, so .getOne and .getMany might still have an old reference and read stale values in CI where the machines have less power and are under more load. Locally, it always passes either way.

The “fix” here is to take the first expectation after awaiting the network request and also wrap it in an await waitFor(...) so that it automatically retries if the first attempt fails.

Note that all further calls can be kept synchronously because if the first one succeeds, the others should too.


Copied from getsentry#101062
Original PR: getsentry#101062

Copy link

Stabilize Flaky Replay Tests by Using waitFor on Initial Assertions

This pull request modifies the test file static/app/utils/replayCount/useReplayCount.spec.tsx to address flakiness observed in CI runs. The core change is the introduction of await waitFor(...) around the first set of assertions following asynchronous network requests, ensuring that state updates resulting from those requests are reliably completed before proceeding. This compensates for asynchronous behavior where the result state may not yet be updated after the network call, which led to intermittent test failures under CI load.

Key Changes

• Wrapped the initial expect statements that check the result of getOne and getMany after network requests in await waitFor(...).
• Maintained synchronous assertions for subsequent expectations, based on the assumption that once the first assertion passes, subsequent state is stable.
• Applied this pattern throughout all relevant test cases in static/app/utils/replayCount/useReplayCount.spec.tsx.

Affected Areas

static/app/utils/replayCount/useReplayCount.spec.tsx (test logic only)

This summary was automatically generated by @propel-code-bot

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