diff --git a/packages/playwright-ct-vue/index.d.ts b/packages/playwright-ct-vue/index.d.ts index f992773bee5af..41b7575f02db8 100644 --- a/packages/playwright-ct-vue/index.d.ts +++ b/packages/playwright-ct-vue/index.d.ts @@ -35,21 +35,31 @@ export type PlaywrightTestConfig = Omit & { default?: ComponentSlot }; -export interface MountOptions< - HooksConfig extends JsonObject, - Props extends Record -> { - props?: Props; - slots?: Record & { default?: Slot }; - on?: Record; +type ComponentEvents = Record; + +// Copied from: https://github.com/vuejs/language-tools/blob/master/packages/vue-component-type-helpers/index.d.ts#L10-L13 +type ComponentProps = + T extends new () => { $props: infer P; } ? NonNullable

: + T extends (props: infer P, ...args: any) => any ? P : + {}; + +export interface MountOptions { + props?: ComponentProps; + slots?: ComponentSlots; + on?: ComponentEvents; hooksConfig?: HooksConfig; } -interface MountResult> extends Locator { +interface MountResult extends Locator { unmount(): Promise; - update(options: Omit, 'hooksConfig'>): Promise; + update(options: { + props?: Partial>; + slots?: Partial; + on?: Partial; + }): Promise; } interface MountResultJsx extends Locator { @@ -59,17 +69,10 @@ interface MountResultJsx extends Locator { export interface ComponentFixtures { mount(component: JSX.Element): Promise; - mount( - component: any, - options?: MountOptions> - ): Promise>>; - mount< - HooksConfig extends JsonObject, - Props extends Record = Record - >( - component: any, - options: MountOptions & { props: Props } - ): Promise>; + mount( + component: Component, + options?: MountOptions + ): Promise>; } export const test: TestType< @@ -77,9 +80,6 @@ export const test: TestType< PlaywrightWorkerArgs & PlaywrightWorkerOptions >; -/** - * Defines Playwright config - */ export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig; export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig; export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig; diff --git a/tests/components/ct-vue-vite/tsconfig.json b/tests/components/ct-vue-vite/tsconfig.json index d6d2007656811..a1d96a55c5e56 100644 --- a/tests/components/ct-vue-vite/tsconfig.json +++ b/tests/components/ct-vue-vite/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.web.json", - "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "playwright"], + "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "tests/**/*", "playwright"], "compilerOptions": { "baseUrl": ".", "paths": {