Skip to content

Conversation

@wjhsf
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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
@wjhsf
Copy link
Contributor Author

wjhsf commented Jul 10, 2025

/nucleus test

@wjhsf wjhsf merged commit 32557e6 into master Jul 10, 2025
6 checks passed
@wjhsf wjhsf deleted the wjh/wtr-hydration branch July 10, 2025 14:54
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.

3 participants