From f58c7f8dd0f04a030beb0580907dd2936995a4b4 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Mon, 10 Feb 2020 12:26:51 -0800 Subject: [PATCH] add the missing files --- test/tsconfig.json | 11 +++++ test/types.d.ts | 103 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 test/tsconfig.json create mode 100644 test/types.d.ts diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000000..158060dd73 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": false, + "noEmit": true, + "moduleResolution": "node", + "target": "ESNext", + "strictNullChecks": false, + }, + "include": ["*.spec.js", "types.d.ts"] + } \ No newline at end of file diff --git a/test/types.d.ts b/test/types.d.ts new file mode 100644 index 0000000000..5aaa2ef67d --- /dev/null +++ b/test/types.d.ts @@ -0,0 +1,103 @@ +type ServerResponse = import('http').ServerResponse; +type IncomingMessage = import('http').IncomingMessage; + +type Falsy = false|""|0|null|undefined; +interface Expect { + 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; + + toBeGolden(path: string): void; + + not: Expect; +} + +type DescribeFunction = ((name: string, inner: () => void) => void) & {skip(condition: boolean): DescribeFunction}; + +type ItFunction = ((name: string, inner: (state: STATE) => Promise) => void) & {skip(condition: boolean): ItFunction}; + +type TestRunner = { + describe: DescribeFunction; + xdescribe: DescribeFunction; + fdescribe: DescribeFunction; + + it: ItFunction; + xit: ItFunction; + fit: ItFunction; + dit: ItFunction; + + beforeAll, beforeEach, afterAll, afterEach, loadTests; +}; + +interface TestSetup { + testRunner: TestRunner; + product: 'Chromium'|'Firefox'|'WebKit'; + FFOX: boolean; + WEBKIT: boolean; + CHROMIUM: boolean; + MAC: boolean; + LINUX: boolean; + WIN: boolean; + playwright: import('../src/server/browserType').BrowserType; + selectors: import('../src/selectors').Selectors; + expect(value: T): Expect; + defaultBrowserOptions: import('../src/server/browserType').LaunchOptions; + playwrightPath; + headless: boolean; + ASSETS_DIR: string; +} + +type TestState = { + server: TestServer; + httpsServer: TestServer; + sourceServer: TestServer; +}; + +type BrowserState = TestState & { + browser: import('../src/browser').Browser; + browserServer: import('../src/server/browserServer').BrowserServer; + newPage: (options?: import('../src/browserContext').BrowserContextOptions) => Promise; + newContext: (options?: import('../src/browserContext').BrowserContextOptions) => Promise; +}; + +type PageState = BrowserState & { + context: import('../src/browserContext').BrowserContext; + page: import('../src/page').Page; +}; +type ChromiumPageState = PageState & { + browser: import('../src/chromium/crBrowser').CRBrowser; +}; +type TestSuite = (setup: TestSetup) => void; +type BrowserTestSuite = (setup: TestSetup) => void; +type PageTestSuite = (setup: TestSetup) => void; +type ChromiumTestSuite = (setup: TestSetup) => void; + + +interface TestServer { + enableHTTPCache(pathPrefix: string); + setAuth(path: string, username: string, password: string); + enableGzip(path: string); + setCSP(path: string, csp: string); + stop(): Promise; + setRoute(path: string, handler: (message: IncomingMessage, response: ServerResponse) => void); + setRedirect(from: string, to: string); + waitForRequest(path: string): Promise; + reset(); + serveFile(request: IncomingMessage, response: ServerResponse, pathName: string); + + PORT: number; + PREFIX: string; + CROSS_PROCESS_PREFIX: string; + EMPTY_PAGE: string; + +} \ No newline at end of file