|
|
|
|
@ -24,9 +24,13 @@ const { test, run } = suite<SSRTest>(async (config, test_dir) => {
|
|
|
|
|
const Component = (await import(`${test_dir}/_output/server/main.svelte.js`)).default;
|
|
|
|
|
const expected_html = try_read_file(`${test_dir}/_expected.html`);
|
|
|
|
|
const rendered = render(Component, { props: config.props || {} });
|
|
|
|
|
const { body, head, css } = rendered;
|
|
|
|
|
const { body, head } = rendered;
|
|
|
|
|
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_actual.html`, body);
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_output/rendered.html`, body);
|
|
|
|
|
|
|
|
|
|
if (head) {
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_output/rendered_head.html`, head);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
assert_html_equal_with_options(body, expected_html || '', {
|
|
|
|
|
@ -43,38 +47,17 @@ const { test, run } = suite<SSRTest>(async (config, test_dir) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(`${test_dir}/_expected-head.html`)) {
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_actual-head.html`, head);
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(`${test_dir}/_expected_head.html`)) {
|
|
|
|
|
try {
|
|
|
|
|
assert_html_equal_with_options(
|
|
|
|
|
head,
|
|
|
|
|
fs.readFileSync(`${test_dir}/_expected-head.html`, 'utf-8'),
|
|
|
|
|
fs.readFileSync(`${test_dir}/_expected_head.html`, 'utf-8'),
|
|
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
if (should_update_expected()) {
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_expected-head.html`, head);
|
|
|
|
|
console.log(`Updated ${test_dir}/_expected-head.html.`);
|
|
|
|
|
error.message += '\n' + `${test_dir}/main.svelte`;
|
|
|
|
|
} else {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(`${test_dir}/_expected.css`)) {
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_actual.css`, css);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
assert.equal(
|
|
|
|
|
css.replaceAll('\r', ''),
|
|
|
|
|
fs.readFileSync(`${test_dir}/_expected.css`, 'utf-8').replaceAll('\r', '')
|
|
|
|
|
);
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
if (should_update_expected()) {
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_expected.css`, css);
|
|
|
|
|
console.log(`Updated ${test_dir}/_expected.css.`);
|
|
|
|
|
fs.writeFileSync(`${test_dir}/_expected_head.html`, head);
|
|
|
|
|
console.log(`Updated ${test_dir}/_expected_head.html.`);
|
|
|
|
|
error.message += '\n' + `${test_dir}/main.svelte`;
|
|
|
|
|
} else {
|
|
|
|
|
throw error;
|
|
|
|
|
|