Skip to content

Commit 9988752

Browse files
committed
fix
1 parent 48b74a6 commit 9988752

File tree

1 file changed

+33
-9
lines changed
  • packages/svelte/tests/runtime-legacy

1 file changed

+33
-9
lines changed

packages/svelte/tests/runtime-legacy/shared.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export interface RuntimeTest<Props extends Record<string, any> = Record<string,
5959
};
6060
logs: any[];
6161
warnings: any[];
62+
hydrate: Function;
6263
}) => void | Promise<void>;
6364
test_ssr?: (args: { assert: Assert }) => void | Promise<void>;
6465
accessors?: boolean;
@@ -103,6 +104,10 @@ export function runtime_suite(runes: boolean) {
103104
if (config.skip_mode?.includes('hydrate')) return true;
104105
}
105106

107+
if (variant === 'dom' && config.skip_mode?.includes('client')) {
108+
return 'no-test';
109+
}
110+
106111
if (variant === 'ssr') {
107112
if (
108113
(config.mode && !config.mode.includes('server')) ||
@@ -161,6 +166,7 @@ async function run_test_variant(
161166

162167
let logs: string[] = [];
163168
let warnings: string[] = [];
169+
let manual_hydrate = false;
164170

165171
{
166172
// use some crude static analysis to determine if logs/warnings are intercepted.
@@ -180,6 +186,10 @@ async function run_test_variant(
180186
console.log = (...args) => logs.push(...args);
181187
}
182188

189+
if (str.slice(0, i).includes('hydrate')) {
190+
manual_hydrate = true;
191+
}
192+
183193
if (str.slice(0, i).includes('warnings') || config.warnings) {
184194
// eslint-disable-next-line no-console
185195
console.warn = (...args) => {
@@ -297,17 +307,30 @@ async function run_test_variant(
297307

298308
let instance: any;
299309
let props: any;
310+
let hydrate_fn: Function = () => {
311+
throw new Error('Ensure dom mode is skipped');
312+
};
300313

301314
if (runes) {
302315
props = proxy({ ...(config.props || {}) });
303-
304-
const render = variant === 'hydrate' ? hydrate : mount;
305-
instance = render(mod.default, {
306-
target,
307-
props,
308-
intro: config.intro,
309-
recover: config.recover ?? false
310-
});
316+
if (manual_hydrate) {
317+
hydrate_fn = () => {
318+
instance = hydrate(mod.default, {
319+
target,
320+
props,
321+
intro: config.intro,
322+
recover: config.recover ?? false
323+
});
324+
};
325+
} else {
326+
const render = variant === 'hydrate' ? hydrate : mount;
327+
instance = render(mod.default, {
328+
target,
329+
props,
330+
intro: config.intro,
331+
recover: config.recover ?? false
332+
});
333+
}
311334
} else {
312335
instance = createClassComponent({
313336
component: mod.default,
@@ -357,7 +380,8 @@ async function run_test_variant(
357380
raf,
358381
compileOptions,
359382
logs,
360-
warnings
383+
warnings,
384+
hydrate: hydrate_fn
361385
});
362386
}
363387

0 commit comments

Comments
 (0)