1 |
|
2 |
|
3 | declare module 'wct' {
|
4 | import * as events from 'events';
|
5 | import * as http from 'http';
|
6 | import * as wd from 'wd';
|
7 | import * as express from 'express';
|
8 |
|
9 | type Handler = (o: {}, callback: (err: any) => void) => void;
|
10 |
|
11 | export interface BrowserDef extends wd.Capabilities {
|
12 | id: number;
|
13 | url: wd.ValidHost;
|
14 | sessionId: string;
|
15 | deviceName?: string;
|
16 | }
|
17 |
|
18 | export interface Stats {
|
19 | status: string;
|
20 | passing?: number;
|
21 | pending?: number;
|
22 | failing?: number;
|
23 | }
|
24 |
|
25 | export interface Config {
|
26 | suites: string[];
|
27 | output: NodeJS.WritableStream;
|
28 | ttyOutput: boolean;
|
29 | verbose: boolean;
|
30 | quiet?: boolean;
|
31 | expanded: boolean;
|
32 | root: string;
|
33 | testTimeout: number;
|
34 | persistent: boolean;
|
35 | extraScripts: string[];
|
36 | clientOptions: {
|
37 | root: string;
|
38 | verbose?: boolean;
|
39 | };
|
40 | activeBrowsers: BrowserDef[];
|
41 | browserOptions: {
|
42 | [name: string]: wd.Capabilities;
|
43 | };
|
44 | plugins: (string | boolean)[] | {
|
45 | [key: string]: ({
|
46 | disabled: boolean;
|
47 | } | boolean);
|
48 | };
|
49 | registerHooks: (wct: Context) => void;
|
50 | enforceJsonConf: boolean;
|
51 | webserver: {
|
52 | port: number;
|
53 | hostname: string;
|
54 | pathMappings: {
|
55 | [urlPath: string]: string;
|
56 | }[];
|
57 | urlPrefix: string;
|
58 | webRunnerPath?: string;
|
59 | webRunnerContent?: string;
|
60 | staticContent?: {
|
61 | [file: string]: string;
|
62 | };
|
63 | };
|
64 | skipPlugins?: boolean;
|
65 | sauce?: {};
|
66 | remote?: {};
|
67 | origSuites?: string[];
|
68 | skipCleanup?: boolean;
|
69 | simpleOutput?: boolean;
|
70 | skipUpdateCheck?: boolean;
|
71 | }
|
72 |
|
73 | |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | export class Context extends events.EventEmitter {
|
80 | options: Config;
|
81 | private _hookHandlers;
|
82 | constructor(options: Config);
|
83 | /**
|
84 | * Registers a handler for a particular hook. Hooks are typically configured to
|
85 | * run _before_ a particular behavior.
|
86 | */
|
87 | hook(name: string, handler: Handler): void;
|
88 | /**
|
89 | * Registers a handler that will run after any handlers registered so far.
|
90 | *
|
91 | * @param {string} name
|
92 | * @param {function(!Object, function(*))} handler
|
93 | */
|
94 | hookLate(name: string, handler: Handler): void;
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | emitHook(name: 'prepare:webserver', app: express.Application, done: (err?: any) => void): Context;
|
109 | emitHook(name: 'configure', done: (err?: any) => void): Context;
|
110 | emitHook(name: 'prepare', done: (err?: any) => void): Context;
|
111 | emitHook(name: 'cleanup', done: (err?: any) => void): Context;
|
112 | emitHook(name: string, done: (err?: any) => void): Context;
|
113 | emitHook(name: string, ...args: any[]): Context;
|
114 | |
115 |
|
116 |
|
117 |
|
118 | plugins(done: (err: any, plugins?: Plugin[]) => void): void;
|
119 | private _plugins();
|
120 | |
121 |
|
122 |
|
123 | enabledPlugins(): string[];
|
124 | |
125 |
|
126 |
|
127 |
|
128 | pluginOptions(name: string): any;
|
129 | static Context: typeof Context;
|
130 | }
|
131 |
|
132 | export interface Metadata {
|
133 | 'cli-options': Config;
|
134 | }
|
135 | export interface PluginInterface {
|
136 | (context: Context, pluginOptions: any, pluginMeta: Plugin): void;
|
137 | }
|
138 | |
139 |
|
140 |
|
141 |
|
142 | export class Plugin {
|
143 | name: string;
|
144 | cliConfig: Config;
|
145 | packageName: string;
|
146 | metadata: Metadata;
|
147 | constructor(packageName: string, metadata: Metadata);
|
148 | /**
|
149 | * @param {!Context} context The context that this plugin should be evaluated
|
150 | * within.
|
151 | * @param {function(*)} done
|
152 | */
|
153 | execute(context: Context, done: (message?: string) => void): void;
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | static get(name: string, done: (err: any, plugin?: Plugin) => void): void;
|
161 | |
162 |
|
163 |
|
164 |
|
165 | static shortName(name: string): string;
|
166 | static Plugin: typeof Plugin;
|
167 | }
|
168 |
|
169 | }
|