Skip to content

Commit 7418f17

Browse files
authored
Fix inconsistent playwright test (#461)
* Remove sleep fixture Playwright has a built-in "slowmo" feature that would be easiest to use. https://playwright.dev/python/docs/test-runners#cli-arguments * Use standard python comparison operator The `to_equal` doesn't seem to exist in playwright for python. There is a NodeJS equivalent, but there is no supported GenericAssertion equivalent for python https://playwright.dev/docs/api/class-genericassertions * Add explanation to test assertion * Fix linting issues
1 parent 56bc49a commit 7418f17

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

tests/test.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import time
2-
31
import pytest
42
from playwright.sync_api import Page, expect
53

@@ -14,13 +12,6 @@
1412
]
1513

1614

17-
# Add a delay to each test to help with playwright race conditions
18-
@pytest.fixture(autouse=True)
19-
def slow_down_tests():
20-
yield
21-
time.sleep(1)
22-
23-
2415
@pytest.mark.parametrize("url", routes)
2516
def test_destination(
2617
page: Page,
@@ -29,7 +20,8 @@ def test_destination(
2920
"""Test that the destinations page loads with seeded data"""
3021
# Create a destination
3122
response = page.goto(f"{live_server_url}/{url}")
32-
page.on("response", lambda response: expect(response.status).to_equal(200))
23+
24+
assert response.status == 200 # Check that the page loaded successfully
3325
assert response.url.endswith(f"/{url}/") # Load the index.html
3426

3527

0 commit comments

Comments
 (0)