Skip to content

Commit 698eed9

Browse files
committed
Attempt fix for flakey tests: Check if new page already exists before waiting for page event.
1 parent 8875643 commit 698eed9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/test_router.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from reactpy_router import browser_router, link, navigate, route, use_params, use_search_params
1111

1212
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "").lower() == "true"
13-
CLICK_DELAY = 500 if GITHUB_ACTIONS else 25 # Delay in miliseconds.
13+
CLICK_DELAY = 350 if GITHUB_ACTIONS else 25 # Delay in miliseconds.
1414
pytestmark = pytest.mark.anyio
1515

1616

@@ -279,7 +279,10 @@ def sample():
279279
_link = await display.page.wait_for_selector("#root")
280280
await _link.click(delay=CLICK_DELAY, modifiers=["Control"])
281281
browser_context = browser.contexts[0]
282-
new_page: Page = await browser_context.wait_for_event("page")
282+
if len(browser_context.pages) == 1:
283+
new_page: Page = await browser_context.wait_for_event("page")
284+
else:
285+
new_page: Page = browser_context.pages[-1] # type: ignore[no-redef]
283286
await new_page.wait_for_selector("#a")
284287

285288

0 commit comments

Comments
 (0)