2022-03-12 00:00:46 +08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2025-08-06 03:40:57 +08:00
|
|
|
import type { ComponentProps, Component, SvelteComponent } from 'svelte';
|
2024-07-17 01:32:51 +08:00
|
|
|
import type { TestType, Locator } from '@playwright/experimental-ct-core';
|
2022-05-07 03:02:07 +08:00
|
|
|
|
2025-08-06 03:40:57 +08:00
|
|
|
type ComponentSlot = Snippet | string;
|
2023-05-23 04:18:56 +08:00
|
|
|
type ComponentSlots = Record<string, ComponentSlot> & { default?: ComponentSlot };
|
|
|
|
type ComponentEvents = Record<string, Function>;
|
2022-09-08 23:39:00 +08:00
|
|
|
|
2025-08-06 03:40:57 +08:00
|
|
|
// TODO: Remove after Svelte has removed S4 fallback TypeScript types for `*.svelte` files
|
|
|
|
type InteropComponent = (new (...args: unknown[]) => SvelteComponent) | Component<any, any, any>;
|
|
|
|
|
|
|
|
export interface MountOptions<HooksConfig, Component extends InteropComponent> {
|
2022-09-13 00:30:04 +08:00
|
|
|
props?: ComponentProps<Component>;
|
2023-05-23 04:18:56 +08:00
|
|
|
slots?: ComponentSlots;
|
|
|
|
on?: ComponentEvents;
|
2022-10-19 04:04:54 +08:00
|
|
|
hooksConfig?: HooksConfig;
|
2022-08-30 00:10:50 +08:00
|
|
|
}
|
|
|
|
|
2025-08-06 03:40:57 +08:00
|
|
|
export interface MountResult<Component extends InteropComponent> extends Locator {
|
2022-07-30 11:07:23 +08:00
|
|
|
unmount(): Promise<void>;
|
2023-05-23 04:18:56 +08:00
|
|
|
update(options: {
|
|
|
|
props?: Partial<ComponentProps<Component>>;
|
|
|
|
on?: Partial<ComponentEvents>;
|
|
|
|
}): Promise<void>;
|
2022-07-30 11:07:23 +08:00
|
|
|
}
|
|
|
|
|
2025-09-18 20:23:45 +08:00
|
|
|
export interface ComponentFixtures {
|
2025-08-06 03:40:57 +08:00
|
|
|
mount<HooksConfig, Component extends InteropComponent = InteropComponent>(
|
|
|
|
component: Component,
|
2022-10-19 04:04:54 +08:00
|
|
|
options?: MountOptions<HooksConfig, Component>
|
2022-10-11 03:45:48 +08:00
|
|
|
): Promise<MountResult<Component>>;
|
2025-09-18 20:23:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export const test: TestType<ComponentFixtures>;
|
2023-01-13 05:12:02 +08:00
|
|
|
|
2024-07-17 01:32:51 +08:00
|
|
|
export { defineConfig, PlaywrightTestConfig, expect, devices } from '@playwright/experimental-ct-core';
|