pull/16056/head
Rich Harris 4 months ago
parent 03273b7879
commit 7c10b237d1

@ -121,13 +121,12 @@ export function normalize_new_line(html) {
return html.replace(/\r\n/g, '\n'); return html.replace(/\r\n/g, '\n');
} }
export function setup_html_equal() {
/** /**
* @param {string} actual * @param {string} actual
* @param {string} expected * @param {string} expected
* @param {string} [message] * @param {string} [message]
*/ */
const assert_html_equal = (actual, expected, message) => { export const assert_html_equal = (actual, expected, message) => {
try { try {
assert.deepEqual(normalize_html(window, actual), normalize_html(window, expected), message); assert.deepEqual(normalize_html(window, actual), normalize_html(window, expected), message);
} catch (e) { } catch (e) {
@ -144,7 +143,7 @@ export function setup_html_equal() {
* @param {{ preserveComments?: boolean, withoutNormalizeHtml?: boolean }} param2 * @param {{ preserveComments?: boolean, withoutNormalizeHtml?: boolean }} param2
* @param {string} [message] * @param {string} [message]
*/ */
const assert_html_equal_with_options = ( export const assert_html_equal_with_options = (
actual, actual,
expected, expected,
{ preserveComments, withoutNormalizeHtml }, { preserveComments, withoutNormalizeHtml },
@ -172,12 +171,3 @@ export function setup_html_equal() {
throw e; throw e;
} }
}; };
return {
assert_html_equal,
assert_html_equal_with_options
};
}
// Common case without options
export const { assert_html_equal, assert_html_equal_with_options } = setup_html_equal();

@ -7,7 +7,7 @@ import { flushSync, hydrate, mount, unmount } from 'svelte';
import { render } from 'svelte/server'; import { render } from 'svelte/server';
import { afterAll, assert, beforeAll } from 'vitest'; import { afterAll, assert, beforeAll } from 'vitest';
import { compile_directory, fragments } from '../helpers.js'; import { compile_directory, fragments } from '../helpers.js';
import { setup_html_equal } from '../html_equal.js'; import { assert_html_equal, assert_html_equal_with_options } from '../html_equal.js';
import { raf } from '../animation-helpers.js'; import { raf } from '../animation-helpers.js';
import type { CompileOptions } from '#compiler'; import type { CompileOptions } from '#compiler';
import { suite_with_variants, type BaseTest } from '../suite.js'; import { suite_with_variants, type BaseTest } from '../suite.js';
@ -86,8 +86,6 @@ function unhandled_rejection_handler(err: Error) {
const listeners = process.rawListeners('unhandledRejection'); const listeners = process.rawListeners('unhandledRejection');
const { assert_html_equal, assert_html_equal_with_options } = setup_html_equal();
beforeAll(() => { beforeAll(() => {
// @ts-expect-error TODO huh? // @ts-expect-error TODO huh?
process.prependListener('unhandledRejection', unhandled_rejection_handler); process.prependListener('unhandledRejection', unhandled_rejection_handler);

Loading…
Cancel
Save