Skip to content

Improvements for asserting HTML in text#59161

Open
jasonmccreary wants to merge 2 commits intolaravel:13.xfrom
jasonmccreary:ignore-whitespace
Open

Improvements for asserting HTML in text#59161
jasonmccreary wants to merge 2 commits intolaravel:13.xfrom
jasonmccreary:ignore-whitespace

Conversation

@jasonmccreary
Copy link
Contributor

This PR resolves some papercuts with assertSeeText and similar assertions:

  • It normalizes whitespace. It's standard for HTML to treat multiple, consecutive whitespace as a single space.
  • It outputs the original response HTML. Similar to the above, without the full HTML it can be hard to diagnose why these assertions are failing.
  • It removes the redundant Failed asserting that prefix added to the assertion failures.

A few notes. First, to minimize the footprint, I created a single constraint class (SeeInHtml) with multiple parameter flags, rather than multiple, very similar constraint classes (e.g. SeeInHtml, NotSeeInHtml, SeeInHtmlInOrder).

Second, there were some recent changes to these assertions in 12.x which may create a conflict when merging with 13.x.

Finally, while not a breaking change in code per se, I targeted 13.x as it is a change in the behavior/output. Although the developer should not see this since both the expected and actual values are normalized. Meaning if a developer was indeed checking for exact whitespace within their HTML text, their assertion should still pass.

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