small tweak to aid greppability

pull/16781/head
Rich Harris 4 weeks ago
parent a84c78b9a1
commit 41f0ff4115

@ -67,18 +67,19 @@ const { test, run } = suite_with_variants<SSRTest, 'sync' | 'async', CompileOpti
async (config, test_dir, variant, compile_options) => { async (config, test_dir, variant, compile_options) => {
const Component = (await import(`${test_dir}/_output/server/main.svelte.js`)).default; const Component = (await import(`${test_dir}/_output/server/main.svelte.js`)).default;
const expected_html = try_read_file(`${test_dir}/_expected.html`); const expected_html = try_read_file(`${test_dir}/_expected.html`);
const is_async = variant === 'async';
let rendered; let rendered;
try { try {
rendered = rendered = is_async
variant === 'async' ? await renderAsync(Component, {
? await renderAsync(Component, { props: config.props || {},
props: config.props || {}, idPrefix: config.id_prefix
idPrefix: config.id_prefix })
}) : render(Component, {
: render(Component, { props: config.props || {},
props: config.props || {}, idPrefix: config.id_prefix
idPrefix: config.id_prefix });
});
} catch (error) { } catch (error) {
if (config.error) { if (config.error) {
assert.deepEqual((error as Error).message, config.error); assert.deepEqual((error as Error).message, config.error);
@ -90,11 +91,16 @@ const { test, run } = suite_with_variants<SSRTest, 'sync' | 'async', CompileOpti
const { body, head } = rendered; const { body, head } = rendered;
const prefix = variant === 'async' ? 'async_' : ''; fs.writeFileSync(
fs.writeFileSync(`${test_dir}/_output/${prefix}rendered.html`, body); `${test_dir}/_output/${is_async ? 'async_rendered.html' : 'rendered.html'}`,
body
);
if (head) { if (head) {
fs.writeFileSync(`${test_dir}/_output/${prefix}rendered_head.html`, head); fs.writeFileSync(
`${test_dir}/_output/${is_async ? 'async_rendered_head.html' : 'rendered_head.html'}`,
head
);
} }
try { try {

Loading…
Cancel
Save