chore: improve hydration tests #10887
Merged
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.
Right now, we test hydration by inserting the contents of a
_before.html
file, hydrating, and checking that we have the expected output. These_before.html
files are created manually.This is both extremely laborious — this PR is the outcome of frustrations I had while trying to debug something hydration-related — and quite bug-prone.
As a case in point, there is currently a failing test on this branch, and I'm pretty sure it's a legitimate failure (i.e. a real bug was being masked by an incorrectnow fixed_before.html
).This PR simplifies things:
server_props
object to the test interface, and use that for SSR if it exists_before.html
file<head>
contents) are written to the_output
directory, alongside the compiler output_expected.html
(formerly_after.html
) and compare against that, otherwise we compare against the initial SSR'd HTMLAs well as being much simpler and more maintainable, this will aid us if we implement something like #10609 (which we should).
TODO: