Skip to content

fix: [#2022] Make DetachedWindowAPI abort() test deterministic#2023

Open
TrevorBurnham wants to merge 1 commit intocapricorn86:masterfrom
TrevorBurnham:fix/flaky-detached-window-api-test
Open

fix: [#2022] Make DetachedWindowAPI abort() test deterministic#2023
TrevorBurnham wants to merge 1 commit intocapricorn86:masterfrom
TrevorBurnham:fix/flaky-detached-window-api-test

Conversation

@TrevorBurnham
Copy link
Copy Markdown
Contributor

Fixes #2022

Problem

The test DetachedWindowAPI > abort() > Cancels all ongoing asynchrounous tasks was flaky in CI, timing out with a 500ms limit. The test used setTimeout(..., 10) to check if waitUntilComplete() promises had resolved, which is unreliable in CI environments under load.

// Before (flaky)
setTimeout(() => {
    expect(isFirstWhenAsyncCompleteCalled).toBe(true);
    expect(isSecondWhenAsyncCompleteCalled).toBe(true);
    resolve(null);
}, 10);

Solution

Replaced the timing-based assertion with direct promise awaiting:

// After (deterministic)
await Promise.all([firstWaitPromise, secondWaitPromise]);

Changes:

  • Directly await the waitUntilComplete() promises using Promise.all()
  • Remove the manual Promise wrapper and setTimeout-based assertion
  • Keep the synchronous tasksDone check immediately after abort()

…stic

The test 'Cancels all ongoing asynchrounous tasks' was flaky because it
used setTimeout with a 10ms delay to check if waitUntilComplete()
promises had resolved. This timing-based approach is unreliable in CI
environments.

Changed the test to:
- Directly await the waitUntilComplete() promises using Promise.all()
- Remove the manual Promise wrapper and setTimeout-based assertion
- Keep the synchronous tasksDone check immediately after abort()

This makes the test deterministic by awaiting promises directly rather
than relying on arbitrary timeouts.
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.

Flaky test: Timeout in DetachedWindowAPI

1 participant