Skip to content

Conversation

@KaiPrince
Copy link
Contributor

@KaiPrince KaiPrince commented Nov 15, 2025

This PR updates a test to use self-closing tags. This will make it compatible with Prettier and unblock #209 using self closing tags in the test files, but running them through parser5 in the tests, we get the best of both world: compliant html & auto formatting.

Related Issue

Resolves #210

Summary of Changes

  1. Add /> to a test expected.html file
  2. Run the expected html through the parser before comparing it in the test

<img src="https://www.greenwoodjs.io/assets/greenwood-logo-og.png" alt="Greenwood logo">
<br>
<img src="https://www.greenwoodjs.io/assets/greenwood-logo-og.png" alt="Greenwood logo" />
<br />
Copy link
Member

@thescientist13 thescientist13 Nov 19, 2025

Choose a reason for hiding this comment

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

hmm, I thought the issue was that the expected would be without the closing / for these void elements?

I can understand if we start with <img/> but end up with <img> but shouldn't parse5 be stripping the closing / and thus the expected should be <img>?

pictureFrame = dom.window.document.querySelectorAll('wcc-picture-frame');
expectedHtml = await fs.readFile(new URL('./expected.html', import.meta.url), 'utf-8');
const rawExpectedHtml = await fs.readFile(new URL('./expected.html', import.meta.url), 'utf-8');
expectedHtml = serialize(parseFragment(rawExpectedHtml));
Copy link
Member

@thescientist13 thescientist13 Nov 19, 2025

Choose a reason for hiding this comment

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

Oh, I see yes, you said you would run the expected HTML through parse5, thus getting our compliant HTML output.

Maybe we can just leave a comment here regarding this just to add a little context for this change here?

@thescientist13 thescientist13 changed the title chore: use self-closing tags in tests chore: #210 use self-closing tags in tests Nov 19, 2025
@thescientist13 thescientist13 force-pushed the kprince/fix-test-with-void-tags branch from 52ad4f7 to 43b2f4f Compare November 19, 2025 14:25
Copy link
Member

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

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

Thanks!

@thescientist13 thescientist13 merged commit 398d8d6 into ProjectEvergreen:master Nov 19, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests should use conventional self-closing tags (i.e. <img />)

2 participants