|
|
|
@ -3,7 +3,7 @@ import { setImmediate } from 'node:timers/promises';
|
|
|
|
|
import glob from 'tiny-glob/sync.js';
|
|
|
|
|
import * as $ from 'svelte/internal/client';
|
|
|
|
|
import { createClassComponent } from 'svelte/legacy';
|
|
|
|
|
import { flushSync } from 'svelte';
|
|
|
|
|
import { flushSync, hydrate, mount, unmount } from 'svelte';
|
|
|
|
|
import { render } from 'svelte/server';
|
|
|
|
|
import { afterAll, assert, beforeAll } from 'vitest';
|
|
|
|
|
import { compile_directory } from '../helpers.js';
|
|
|
|
@ -119,7 +119,7 @@ export function runtime_suite(runes: boolean) {
|
|
|
|
|
return common_setup(cwd, runes, config);
|
|
|
|
|
},
|
|
|
|
|
async (config, cwd, variant, common) => {
|
|
|
|
|
await run_test_variant(cwd, config, variant, common);
|
|
|
|
|
await run_test_variant(cwd, config, variant, common, runes);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -147,7 +147,8 @@ async function run_test_variant(
|
|
|
|
|
cwd: string,
|
|
|
|
|
config: RuntimeTest,
|
|
|
|
|
variant: 'dom' | 'hydrate' | 'ssr',
|
|
|
|
|
compileOptions: CompileOptions
|
|
|
|
|
compileOptions: CompileOptions,
|
|
|
|
|
runes: boolean
|
|
|
|
|
) {
|
|
|
|
|
let unintended_error = false;
|
|
|
|
|
|
|
|
|
@ -256,15 +257,35 @@ async function run_test_variant(
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const instance = createClassComponent({
|
|
|
|
|
component: mod.default,
|
|
|
|
|
props: config.props,
|
|
|
|
|
target,
|
|
|
|
|
immutable: config.immutable,
|
|
|
|
|
intro: config.intro,
|
|
|
|
|
recover: config.recover ?? false,
|
|
|
|
|
hydrate: variant === 'hydrate'
|
|
|
|
|
});
|
|
|
|
|
let instance: any;
|
|
|
|
|
let props: any;
|
|
|
|
|
|
|
|
|
|
if (runes) {
|
|
|
|
|
props = $.proxy({ ...(config.props || {}) });
|
|
|
|
|
|
|
|
|
|
// TODO get rid
|
|
|
|
|
props.$set = (new_props: Record<string, any>) => {
|
|
|
|
|
Object.assign(props, new_props);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const render = variant === 'hydrate' ? hydrate : mount;
|
|
|
|
|
instance = render(mod.default, {
|
|
|
|
|
target,
|
|
|
|
|
props,
|
|
|
|
|
intro: config.intro,
|
|
|
|
|
recover: config.recover ?? false
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
instance = createClassComponent({
|
|
|
|
|
component: mod.default,
|
|
|
|
|
props: config.props,
|
|
|
|
|
target,
|
|
|
|
|
immutable: config.immutable,
|
|
|
|
|
intro: config.intro,
|
|
|
|
|
recover: config.recover ?? false,
|
|
|
|
|
hydrate: variant === 'hydrate'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.warn = warn;
|
|
|
|
@ -303,7 +324,7 @@ async function run_test_variant(
|
|
|
|
|
htmlEqualWithOptions: assert_html_equal_with_options
|
|
|
|
|
},
|
|
|
|
|
variant,
|
|
|
|
|
component: instance,
|
|
|
|
|
component: runes ? props : instance,
|
|
|
|
|
mod,
|
|
|
|
|
target,
|
|
|
|
|
snapshot,
|
|
|
|
@ -318,7 +339,12 @@ async function run_test_variant(
|
|
|
|
|
assert.fail('Expected a runtime error');
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
instance.$destroy();
|
|
|
|
|
if (runes) {
|
|
|
|
|
unmount(instance);
|
|
|
|
|
} else {
|
|
|
|
|
instance.$destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert_html_equal(
|
|
|
|
|
target.innerHTML,
|
|
|
|
|
'',
|
|
|
|
|