Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions playwright/_impl/_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ async def _expect_impl(
expect_options["timeout"] = self._timeout or 5_000
if expect_options["isNot"]:
message = message.replace("expected to", "expected not to")
if title:
title = title.replace('"to_', '"not_to_')
if "useInnerText" in expect_options and expect_options["useInnerText"] is None:
del expect_options["useInnerText"]
result = await self._call_expect(expression, expect_options, title)
Expand Down
9 changes: 9 additions & 0 deletions tests/async/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,15 @@ async def test_should_be_able_to_set_custom_timeout(page: Page) -> None:
assert 'Expect "to_be_visible" with timeout 111ms' in str(exc_info.value)


async def test_negative_assertion_should_show_not_prefix_in_call_log(
Comment thread
Skn0tt marked this conversation as resolved.
Outdated
page: Page,
) -> None:
await page.set_content("<button>hello</button>")
with pytest.raises(AssertionError) as exc_info:
await expect(page.locator("button")).not_to_be_visible(timeout=111)
assert 'Expect "not_to_be_visible" with timeout 111ms' in str(exc_info.value)


async def test_should_be_able_to_set_custom_global_timeout(page: Page) -> None:
try:
expect.set_options(timeout=111)
Expand Down