Skip to content

test(web-test-runner): run hydration tests in CI @W-18780671 #5398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

wjhsf
Copy link
Collaborator

@wjhsf wjhsf commented Jun 25, 2025

Details

Another step of our migration to web-test-runner. Hydration tests are even more annoyingly convoluted than the basic integration tests. First, the component code is bundled into an IIFE and executed in a vm.Script to get the server-side generated markup. Then that, the client-side component code, and test config are wrapped in a generated test function. I've moved some of it to ESM imports, but getting rid of all of the IIFEs means using the experimental vm.Module. (Which will be fine, just more effort, so this PR is a checkpoint.)

Also, apparently this has been broken for a while:

import { setHooks, sanitizeHtmlContent } from "@lwc/ssr-runtime";
setHooks({ sanitizeHtmlContent: (v) => v.toUpperCase() });
sanitizeHtmlContent("foo"); // Error: sanitizeHtmlContent hook must be implemented.

I believe this is because sanitizeHtmlContent was being directly exported. Changing that to a wrapper function and updating a non-exported variable fixed the problem.

Lastly, this also includes some cleaning up of the helper files because they were just a littered dumping ground of utilities.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.
  • 💔 Yes, it does introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.
  • 🔬 Yes, it does include an observable change.

GUS work item

@wjhsf wjhsf requested a review from a team as a code owner June 25, 2025 19:57
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved to a new file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved to a new file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved to a new file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Largely copied from the karma version, with some rekerjiggering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Largely copied from the karma version.

@wjhsf wjhsf enabled auto-merge (squash) June 25, 2025 20:38
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