feat(ct): svelte mount type (#17228)

This commit is contained in:
sand4rt 2022-09-12 18:30:04 +02:00 committed by GitHub
parent 72a18754ef
commit 344077b04e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -24,6 +24,7 @@ import type {
Locator, Locator,
} from '@playwright/test'; } from '@playwright/test';
import type { InlineConfig } from 'vite'; import type { InlineConfig } from 'vite';
import type { SvelteComponent, ComponentProps } from 'svelte/types/runtime'
export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & { export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
use?: BasePlaywrightTestConfig['use'] & { use?: BasePlaywrightTestConfig['use'] & {
@ -36,8 +37,8 @@ export type PlaywrightTestConfig = Omit<BasePlaywrightTestConfig, 'use'> & {
type Slot = string | string[]; type Slot = string | string[];
export interface MountOptions<Props = Record<string, unknown>> { export interface MountOptions<Component extends SvelteComponent> {
props?: Props; props?: ComponentProps<Component>;
slots?: Record<string, Slot> & { default?: Slot }; slots?: Record<string, Slot> & { default?: Slot };
on?: Record<string, Function>; on?: Record<string, Function>;
hooksConfig?: any; hooksConfig?: any;
@ -48,8 +49,10 @@ interface MountResult extends Locator {
} }
interface ComponentFixtures { interface ComponentFixtures {
mount(component: any, options?: MountOptions): Promise<MountResult>; mount<Component extends SvelteComponent>(
mount<Props>(component: any, options: MountOptions & { props: Props }): Promise<MountResult>; component: new (...args: any[]) => Component,
options?: MountOptions<Component>
): Promise<MountResult>;
} }
export const test: TestType< export const test: TestType<

View file

@ -1,6 +1,6 @@
<script> <script lang="ts">
import { createEventDispatcher } from "svelte"; import { createEventDispatcher } from "svelte";
export let title; export let title: string;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
</script> </script>