(
config: ReturnType<typeof import('./assert').test>,
test_dir: string
)
| 13 | import { describe } from 'vitest'; |
| 14 | |
| 15 | export async function run_ssr_test( |
| 16 | config: ReturnType<typeof import('./assert').test>, |
| 17 | test_dir: string |
| 18 | ) { |
| 19 | try { |
| 20 | await compile_directory(test_dir, 'server', config.compileOptions); |
| 21 | |
| 22 | const Component = (await import(`${test_dir}/_output/server/main.svelte.js`)).default; |
| 23 | const { body } = render(Component, { props: config.props || {}, idPrefix: config.id_prefix }); |
| 24 | |
| 25 | fs.writeFileSync(`${test_dir}/_output/rendered.html`, body); |
| 26 | |
| 27 | if (config.ssrHtml) { |
| 28 | assert_html_equal_with_options(body, config.ssrHtml, { |
| 29 | preserveComments: config.compileOptions?.preserveComments |
| 30 | }); |
| 31 | } else if (config.html) { |
| 32 | assert_html_equal_with_options(body, config.html, { |
| 33 | preserveComments: config.compileOptions?.preserveComments |
| 34 | }); |
| 35 | } |
| 36 | } catch (err: any) { |
| 37 | err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), test_dir)}/main.svelte`; |
| 38 | throw err; |
| 39 | } |
| 40 | |
| 41 | // wait for vitest to report progress |
| 42 | await setImmediate(); |
| 43 | } |
| 44 | |
| 45 | const { run } = suite<ReturnType<typeof import('./assert').test>>(async (config, test_dir) => { |
| 46 | if (config.mode && !config.mode.includes('server')) return; |
no test coverage detected