Skip to content

Commit 21064a2

Browse files
committed
sleep with playwright
1 parent 0ff53cd commit 21064a2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tests/async/test_extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async def test_should_give_access_to_the_service_worker(
7575
assert service_worker
7676
assert service_worker in context.service_workers
7777
while not await service_worker.evaluate("globalThis.MAGIC") == 42:
78-
await asyncio.sleep(0.1)
78+
await context.pages[0].wait_for_timeout(100)
7979
await context.close()
8080
assert len(context.background_pages) == 0
8181

@@ -99,7 +99,7 @@ async def test_should_give_access_to_the_service_worker_when_recording_video(
9999
assert service_worker
100100
assert service_worker in context.service_workers
101101
while not await service_worker.evaluate("globalThis.MAGIC") == 42:
102-
await asyncio.sleep(0.1)
102+
await context.pages[0].wait_for_timeout(100)
103103
await context.close()
104104
assert len(context.background_pages) == 0
105105

tests/sync/test_extension.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
from pathlib import Path
16-
from time import sleep
1716
from typing import Any, Callable, Dict, Generator, List, Optional
1817

1918
import pytest
@@ -73,7 +72,7 @@ def test_should_give_access_to_the_service_worker(
7372
assert service_worker
7473
assert service_worker in context.service_workers
7574
while not service_worker.evaluate("globalThis.MAGIC") == 42:
76-
sleep(0.1)
75+
context.pages[0].wait_for_timeout(100)
7776
context.close()
7877
assert len(context.background_pages) == 0
7978

@@ -97,6 +96,6 @@ def test_should_give_access_to_the_service_worker_when_recording_video(
9796
assert service_worker
9897
assert service_worker in context.service_workers
9998
while not service_worker.evaluate("globalThis.MAGIC") == 42:
100-
sleep(0.1)
99+
context.pages[0].wait_for_timeout(100)
101100
context.close()
102101
assert len(context.background_pages) == 0

0 commit comments

Comments
 (0)