Open westonruter opened 3 months ago
There is even an
assertMatchesHtmlSnapshot()
assertion we can use instead ofassertEquals
which does normalization which would reduce the need to useremove_initial_tabs
. (Nevertheless, theHtmlDriver
is using PHP DOM which has limitations.)
As a start we could also think about writing our own custom assertions first, or write a custom driver for that package.
It's interesting that assertMatchesHtmlSnapshot()
ends up using assertEquals
on the serialized HTML, rather than comparing DOMDocument instances.
I recall that @dmsnell also maybe has implemented such an HTML-equivalency algorithm using HTML (Tag?) Processor?
@westonruter we have primitive forms with the Tag Processor, but I think that the HTML Processor will, for the most part, support all† HTML in 6.7, making it possible to propose something in Core for a new assertion.
PHP 8.4 will have a spec-compliant HTML5 parser based on lexbor
which will also do the trick and support everything, but in most cases I believe we will have an effective tool with the HTML API, but it doesn't exist yet in a proposal.
With https://github.com/WordPress/performance/pull/1405, the Optimization Detective tests were refactored to be easier to maintain by putting the test cases into separate files. However, when changes occur to the actual HTML output they remain tedious to update. We should consider using phpunit-snapshot-assertions to make this easier. There is even an
assertMatchesHtmlSnapshot()
assertion we can use instead ofassertEquals
which does normalization which would reduce the need to useremove_initial_tabs
. (Nevertheless, theHtmlDriver
is using PHP DOM which has limitations.)Relevant code that this would touch (in addition to the
test-cases
subdirectories):