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.

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