Skip to content

fix: count a failed browser check as an assertion - #298

Open
vasikmansuri wants to merge 1 commit into
pestphp:5.xfrom
vasikmansuri:fix/count-failed-browser-check
Open

vasikmansuri wants to merge 1 commit into
pestphp:5.xfrom
vasikmansuri:fix/count-failed-browser-check

Conversation

@vasikmansuri

Copy link
Copy Markdown

Fixes case 1 of pestphp/pest#2009.

A test whose first browser check fails, e.g. visit('/ok')->assertSee('Goodbye'), is reported as failed with 0 assertions and also as risky ("This test did not perform any assertions"). assertSee(), assertDontSee(), failed actions and GuessLocator throw ExpectationFailedException without counting an assertion, while PHPUnit's own assertions count before they throw.

Every failing page call goes through the catch (ExpectationFailedException) in AwaitableWebpage::__call(), so this counts the failed check there, once, instead of before each throw.

Test: counts a failed check as an assertion in AssertSeeTest fails without the change (0 vs 1) and passes with it. The full tests/Browser suite passes locally (277 tests).

Cases 2 and 3 of the issue (a server exception from an earlier page reaching later pages, and the plugin's frames in failure traces) are left for separate PRs.

@vasikmansuri
vasikmansuri force-pushed the fix/count-failed-browser-check branch from 3732449 to 753678c Compare November 17, 2026 06:14
@vasikmansuri

Copy link
Copy Markdown
Author

Rebased onto current 5.x (753678c). The only conflict was the new retry test from #276 sitting at the same spot in AssertSeeTest.php; both tests are kept. The AwaitableWebpage change is unchanged.

The red run from yesterday was the type-coverage step (AnalyserResult::getCollectedData() undefined, pestphp/pest#2034), not this change. That's fixed upstream and 5.x is green again.

Locally on the rebased branch: tests/Browser 283 passed, rector, pint, phpstan and type coverage (100%) all clean.

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.

1 participant