Repository navigation
feat: give each check an optional message for the reason of a failure - #3
Merged
Merged
Conversation
The 23 methods of AssertsHtml, the 22 expectations of Pest and eachMatch take a last parameter $message. A failure shows it first. A value that is not a page and a missing region now stop the test with NotAPage, NotOneNode or NoMatch, so ->not cannot pass on them.
sorge-it
force-pushed
the
feat/assertion-messages
branch
from
October 6, 2026 10:07
e080b27 to
42e54c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Each check takes a last, optional parameter
string $message = '', as the checks of PHPUnit and Pest do. A failure shows it first:AssertsHtml, 22 expectations of Pest andeachMatch.$valueoftoHaveSelectorAttribute(), the message goes by name:message: '…'.Fixed
A wrong input or a missing region failed with an
AssertionFailedError. Pest's->notcatches that and turned the check into a pass. These now stop the test with aLogicException, also under->not:NotAPage: a value that is not a page, and a frame withoutsrcdoc.NotOneNode:within()andframe()where the selector finds no node or more than one.NoMatch:eachMatch()where no node matches.->not->eachMatch()stops with aLogicException: it would pass where one match fails.The message of the test comes first in each of them.
Upgrade
AssertsHtmladdsstring $message = ''.Test
composer teston PHP 8.5: 214 tests, PHPStan max, type coverage 100 %.