fix: hydrate types

paoloricciuti 3 months ago committed by GitHub
parent 6411c4282d
commit 0cebd320f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -28,13 +28,13 @@ type NonAssertingMethods = {
type Assert = Omit<typeof import('vitest').assert, keyof NonAssertingMethods> & NonAssertingMethods; type Assert = Omit<typeof import('vitest').assert, keyof NonAssertingMethods> & NonAssertingMethods;
export interface CustomRendererTest extends BaseTest { interface CustomRendererHydrateTest extends BaseTest {
html?: string; html?: string;
compileOptions?: Partial<CompileOptions>; compileOptions?: Partial<CompileOptions>;
props?: Record<string, any>; props?: Record<string, any>;
server_props?: Record<string, any>; server_props?: Record<string, any>;
context?: Map<any, any>; context?: Map<any, any>;
hydrate?: true; hydrate: true;
error?: string; error?: string;
compile_error?: string; compile_error?: string;
compile_warnings?: false; compile_warnings?: false;
@ -42,7 +42,7 @@ export interface CustomRendererTest extends BaseTest {
warnings?: string[]; warnings?: string[];
test?: (args: { test?: (args: {
assert: Assert; assert: Assert;
target: ObjFragment | HTMLElement; target: HTMLElement;
component: Record<string, any>; component: Record<string, any>;
mod: any; mod: any;
logs: any[]; logs: any[];
@ -53,6 +53,33 @@ export interface CustomRendererTest extends BaseTest {
}) => void | Promise<void>; }) => void | Promise<void>;
} }
interface CustomRendererNonHydrateTest extends BaseTest {
html?: string;
compileOptions?: Partial<CompileOptions>;
props?: Record<string, any>;
server_props?: Record<string, any>;
context?: Map<any, any>;
hydrate?: false;
error?: string;
compile_error?: string;
compile_warnings?: false;
runtime_error?: string;
warnings?: string[];
test?: (args: {
assert: Assert;
target: ObjFragment;
component: Record<string, any>;
mod: any;
logs: any[];
warnings: any[];
renderer: typeof renderer;
serialize: typeof serialize;
dispatch_event: typeof dispatch_event;
}) => void | Promise<void>;
}
export type CustomRendererTest = CustomRendererHydrateTest | CustomRendererNonHydrateTest;
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
const console_log = console.log; const console_log = console.log;
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@ -222,7 +249,7 @@ async function run_test(cwd: string, config: CustomRendererTest, compile_options
if (config.test) { if (config.test) {
await config.test({ await config.test({
assert, assert,
target, target: target as never,
component: component ?? {}, component: component ?? {},
mod, mod,
logs, logs,
@ -292,7 +319,7 @@ async function run_hydration_test(
if (config.test) { if (config.test) {
await config.test({ await config.test({
assert, assert,
target, target: target as never,
component, component,
mod, mod,
logs, logs,

Loading…
Cancel
Save