e2ed
Version:
E2E testing framework over Playwright
40 lines (39 loc) • 1.72 kB
TypeScript
import type { Expect as PlaywrightExpect } from '@playwright/test';
import type { Fn, ToMatchScreenshotOptions } from '../../types/internal';
type ElementOf<Type> = Type extends (infer Element)[] ? Element : never;
type EnsureString<Type> = Type extends string ? string : never;
type Extend<Type, Extended> = Type extends Extended ? Extended : never;
type PlaywrightMatchers = ReturnType<PlaywrightExpect>;
/**
* Addition matchers.
*/
export type NonSelectorAdditionalMatchers<Actual> = Readonly<{
contains: <R>(expected: ElementOf<Actual> | EnsureString<Actual> | Extend<Actual, R>) => Promise<void>;
eql: (expected: Actual) => Promise<void>;
gt: (expected: number) => Promise<void>;
gte: (expected: number) => Promise<void>;
lt: (expected: number) => Promise<void>;
lte: (expected: number) => Promise<void>;
match: (re: RegExp) => Promise<void>;
notContains: <R>(unexpected: ElementOf<Actual> | EnsureString<Actual> | Extend<Actual, R>) => Promise<void>;
notEql: (unexpected: Actual) => Promise<void>;
notOk: () => Promise<void>;
ok: () => Promise<void>;
}>;
/**
* All matchers.
*/
export type NonSelectorMatchers<Actual> = NonSelectorAdditionalMatchers<Actual> & {
readonly [Key in keyof PlaywrightMatchers]: Fn<PlaywrightMatchers[Key] extends (...args: infer Args) => unknown ? Args : never, Promise<void>, void>;
};
/**
* Matchers for selector.
* TODO: support LocatorAssertions
*/
export type SelectorMatchers = Readonly<{
/**
* Checks that the selector screenshot matches the one specified by `expectedScreenshotId`.
*/
toMatchScreenshot: (expectedScreenshotId: string, options?: ToMatchScreenshotOptions) => Promise<void>;
}>;
export {};