2020-02-11 00:20:13 +03:00
|
|
|
type ServerResponse = import('http').ServerResponse;
|
|
|
|
type IncomingMessage = import('http').IncomingMessage;
|
|
|
|
|
2020-07-08 10:20:36 +03:00
|
|
|
type Falsy = false|''|0|null|undefined;
|
2020-02-11 00:20:13 +03:00
|
|
|
interface Expect<T> {
|
|
|
|
toBe(other: T, message?: string): void;
|
|
|
|
toBeFalsy(message?: string): void;
|
|
|
|
toBeTruthy(message?: string): void;
|
|
|
|
toContain(other: any, message?: string): void;
|
|
|
|
toEqual(other: T, message?: string): void;
|
|
|
|
toBeNull(message?: string): void;
|
|
|
|
toBeInstanceOf(other: Function, message?: string): void;
|
|
|
|
|
|
|
|
toBeGreaterThan(other: number, message?: string): void;
|
|
|
|
toBeGreaterThanOrEqual(other: number, message?: string): void;
|
|
|
|
toBeLessThan(other: number, message?: string): void;
|
|
|
|
toBeLessThanOrEqual(other: number, message?: string): void;
|
|
|
|
toBeCloseTo(other: number, precision: number, message?: string): void;
|
|
|
|
|
2020-04-14 00:12:44 +03:00
|
|
|
toBeGolden(golden: {goldenPath: string, outputPath: string, goldenName: string}): void;
|
2020-02-11 00:20:13 +03:00
|
|
|
|
|
|
|
not: Expect<T>;
|
|
|
|
}
|
|
|
|
|
2020-03-03 00:47:08 +03:00
|
|
|
type DescribeFunction = ((name: string, inner: () => void) => void) & {fail(condition: boolean): DescribeFunction};
|
2020-02-11 00:20:13 +03:00
|
|
|
|
2020-07-08 10:20:36 +03:00
|
|
|
type ItFunction<STATE> = ((name: string, inner: (state: STATE) => Promise<void>) => void) & {
|
|
|
|
fail(condition: boolean): ItFunction<STATE>;
|
|
|
|
skip(condition: boolean): ItFunction<STATE>;
|
|
|
|
slow(): ItFunction<STATE>;
|
|
|
|
repeat(n: number): ItFunction<STATE>;
|
|
|
|
};
|
2020-02-11 00:20:13 +03:00
|
|
|
|
|
|
|
type TestRunner<STATE> = {
|
|
|
|
describe: DescribeFunction;
|
|
|
|
xdescribe: DescribeFunction;
|
|
|
|
fdescribe: DescribeFunction;
|
|
|
|
|
|
|
|
it: ItFunction<STATE>;
|
|
|
|
xit: ItFunction<STATE>;
|
|
|
|
fit: ItFunction<STATE>;
|
|
|
|
dit: ItFunction<STATE>;
|
|
|
|
|
2020-03-28 18:49:00 +03:00
|
|
|
beforeAll, beforeEach, afterAll, afterEach;
|
2020-02-11 00:20:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
interface TestSetup<STATE> {
|
|
|
|
testRunner: TestRunner<STATE>;
|
|
|
|
product: 'Chromium'|'Firefox'|'WebKit';
|
2020-07-08 10:20:36 +03:00
|
|
|
selectors: import('../index').Selectors;
|
2020-02-11 00:20:13 +03:00
|
|
|
expect<T>(value: T): Expect<T>;
|
|
|
|
playwrightPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
type TestState = {
|
|
|
|
server: TestServer;
|
|
|
|
httpsServer: TestServer;
|
|
|
|
sourceServer: TestServer;
|
|
|
|
};
|
|
|
|
|
|
|
|
type BrowserState = TestState & {
|
2020-08-06 18:27:00 +03:00
|
|
|
playwright: typeof import('../index');
|
|
|
|
browserType: import('../index').BrowserType<import('../index').Browser>;
|
2020-05-23 10:03:57 +03:00
|
|
|
browser: import('../index').Browser;
|
|
|
|
browserServer: import('../index').BrowserServer;
|
2020-08-06 18:27:00 +03:00
|
|
|
defaultBrowserOptions: import('../index').LaunchOptions;
|
2020-02-11 00:20:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
type PageState = BrowserState & {
|
2020-05-23 10:03:57 +03:00
|
|
|
context: import('../index').BrowserContext;
|
|
|
|
page: import('../index').Page;
|
2020-02-11 00:20:13 +03:00
|
|
|
};
|
|
|
|
type ChromiumPageState = PageState & {
|
2020-05-23 10:03:57 +03:00
|
|
|
browser: import('../index').ChromiumBrowser;
|
2020-02-11 00:20:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
interface TestServer {
|
|
|
|
enableHTTPCache(pathPrefix: string);
|
|
|
|
setAuth(path: string, username: string, password: string);
|
|
|
|
enableGzip(path: string);
|
|
|
|
setCSP(path: string, csp: string);
|
|
|
|
stop(): Promise<void>;
|
|
|
|
setRoute(path: string, handler: (message: IncomingMessage, response: ServerResponse) => void);
|
|
|
|
setRedirect(from: string, to: string);
|
|
|
|
waitForRequest(path: string): Promise<IncomingMessage>;
|
|
|
|
reset();
|
|
|
|
serveFile(request: IncomingMessage, response: ServerResponse, pathName: string);
|
2020-02-13 03:27:45 +03:00
|
|
|
|
2020-02-11 00:20:13 +03:00
|
|
|
PORT: number;
|
|
|
|
PREFIX: string;
|
|
|
|
CROSS_PROCESS_PREFIX: string;
|
|
|
|
EMPTY_PAGE: string;
|
2020-02-21 02:15:48 +03:00
|
|
|
}
|
2020-07-08 10:20:36 +03:00
|
|
|
|
|
|
|
declare const describe: DescribeFunction;
|
|
|
|
declare const fdescribe: DescribeFunction;
|
|
|
|
declare const xdescribe: DescribeFunction;
|
|
|
|
declare function expect<T>(value: T): Expect<T>;
|
|
|
|
declare const it: ItFunction<PageState>;
|
|
|
|
declare const fit: ItFunction<PageState>;
|
|
|
|
declare const dit: ItFunction<PageState>;
|
|
|
|
declare const xit: ItFunction<PageState>;
|
|
|
|
|
|
|
|
declare const browserType: import('../index').BrowserType<import('../index').Browser>;
|
|
|
|
|
|
|
|
// global variables in assets
|
2020-08-06 18:27:00 +03:00
|
|
|
declare const testOptions: {
|
|
|
|
FFOX: boolean;
|
|
|
|
WEBKIT: boolean;
|
|
|
|
CHROMIUM: boolean;
|
|
|
|
MAC: boolean;
|
|
|
|
LINUX: boolean;
|
|
|
|
WIN: boolean;
|
|
|
|
HEADLESS: boolean;
|
|
|
|
OUTPUT_DIR: string;
|
|
|
|
USES_HOOKS: boolean;
|
|
|
|
CHANNEL: boolean;
|
|
|
|
};
|
2020-07-08 10:20:36 +03:00
|
|
|
|
|
|
|
// keyboard.html
|
|
|
|
declare function getResult(): string;
|