feat(ct-angular): export the right types

This commit is contained in:
Younes Jaaidi 2024-04-11 14:57:47 +02:00
parent 3449eb8e12
commit 2de7a20a2d
No known key found for this signature in database
GPG key ID: 3126C5717BDF3241

View file

@ -14,20 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
import type { import type { Locator } from 'playwright/test';
Locator,
PlaywrightTestArgs,
PlaywrightTestOptions,
PlaywrightWorkerArgs,
PlaywrightWorkerOptions,
TestType,
} from '@playwright/test';
import type { JsonObject } from '@playwright/experimental-ct-core/types/component'; import type { JsonObject } from '@playwright/experimental-ct-core/types/component';
import type { TestType } from '@playwright/experimental-ct-core';
import type { Provider, Type } from '@angular/core'; import type { Provider, Type } from '@angular/core';
export type { PlaywrightTestConfig } from '@playwright/experimental-ct-core'; export type ComponentEvents = Record<string, Function>;
type ComponentEvents = Record<string, Function>;
export interface MountOptions<HooksConfig extends JsonObject, Component> { export interface MountOptions<HooksConfig extends JsonObject, Component> {
props?: Partial<Component> | Record<string, unknown>, // TODO: filter props and handle signals props?: Partial<Component> | Record<string, unknown>, // TODO: filter props and handle signals
@ -40,8 +32,9 @@ export interface MountTemplateOptions<HooksConfig extends JsonObject, Component>
imports?: Type<unknown>[]; imports?: Type<unknown>[];
} }
interface MountResult<Component> extends Locator { export interface MountResult<Component> extends Locator {
unmount(): Promise<void>; unmount(): Promise<void>;
update(options: { update(options: {
props?: Partial<Component>, props?: Partial<Component>,
on?: Partial<ComponentEvents>, on?: Partial<ComponentEvents>,
@ -53,19 +46,14 @@ export interface ComponentFixtures {
template: string, template: string,
options?: MountTemplateOptions<HooksConfig, Component> options?: MountTemplateOptions<HooksConfig, Component>
): Promise<MountResult<Component>>; ): Promise<MountResult<Component>>;
mount<HooksConfig extends JsonObject, Component = unknown>( mount<HooksConfig extends JsonObject, Component = unknown>(
component: Type<Component>, component: Type<Component>,
options?: MountOptions<HooksConfig, Component> options?: MountOptions<HooksConfig, Component>
): Promise<MountResult<Component>>; ): Promise<MountResult<Component>>;
} }
export const test: TestType< export const test: TestType<ComponentFixtures>;
PlaywrightTestArgs & PlaywrightTestOptions & ComponentFixtures,
PlaywrightWorkerArgs & PlaywrightWorkerOptions
>;
export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig; export { defineConfig, PlaywrightTestConfig } from '@playwright/experimental-ct-core';
export function defineConfig<T>(config: PlaywrightTestConfig<T>): PlaywrightTestConfig<T>; export { expect, devices } from 'playwright/test';
export function defineConfig<T, W>(config: PlaywrightTestConfig<T, W>): PlaywrightTestConfig<T, W>;
export { expect, devices } from '@playwright/test';