chore: use normalization helper for hydration tests (#17434)

pull/17441/head
Rich Harris 7 months ago committed by GitHub
parent ac7c7646bc
commit 05a85d305a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -131,19 +131,12 @@ const { test, run } = suite<HydrationTest>(async (config, cwd) => {
flushSync();
const normalize = (string: string) =>
string
.trim()
.replaceAll('\r\n', '\n')
.replaceAll('/>', '>')
.replace(/<!--.+?-->/g, '');
const expected = read(`${cwd}/_expected.html`) ?? rendered.html;
assert.equal(normalize(target.innerHTML), normalize(expected));
assert_html_equal(target.innerHTML, expected);
if (rendered.head) {
const expected = read(`${cwd}/_expected_head.html`) ?? rendered.head;
assert.equal(normalize(head.innerHTML), normalize(expected));
assert_html_equal(head.innerHTML, expected);
}
if (config.snapshot) {

Loading…
Cancel
Save