forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathOptions.ts
More file actions
426 lines (407 loc) · 13.6 KB
/
Options.ts
File metadata and controls
426 lines (407 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
import type http from 'node:http'
import type https from 'node:https'
import type { URL } from 'node:url'
import type { Hooks, ServiceEntry } from './Services.js'
import type { ReporterEntry } from './Reporters.js'
export type WebDriverLogTypes = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent'
export type SupportedProtocols = 'webdriver' | 'devtools' | './protocol-stub.js'
export type Agents = { http?: unknown, https?: unknown }
export type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE' | 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'trace'
export interface RequestLibOptions {
agent?: Agents
followRedirect?: boolean
headers?: Record<string, string | string[] | undefined>
https?: Record<string, unknown>
json?: Record<string, unknown>
method?: Method
responseType?: 'json' | 'buffer' | 'text'
retry?: { limit: number, methods?: Method[], calculateDelay?: (retryOptions: { computedValue: number }) => number }
searchParams?: Record<string, string | number | boolean | null | undefined> | URLSearchParams
throwHttpErrors?: boolean
timeout?: { response: number }
url?: URL
path?: string
username?: string
password?: string
body?: unknown
}
export interface RequestLibResponse<Body = unknown> {
url: string;
method: string;
statusCode: number;
statusMessage: string;
req: {
method: string;
path: string;
host: string;
res: RequestLibResponse<Body>;
},
request: {
options: RequestLibOptions;
requestUrl: URL;
response: RequestLibResponse<Body>;
};
ok: boolean;
body?: Body;
rawBody?: Buffer;
}
export interface CustomWdRequestAgent {
request: (url: globalThis.URL, options: Omit<RequestLibOptions, 'url' | 'retry'>) => Promise<RequestLibResponse>
}
export interface ShardOptions {
/**
* Total number of shards
*/
total: number
/**
* Shard index to start from (starts with index 1)
*/
current: number
}
/**
* WebdriverIO allows to connect to different WebDriver endpoints by capability
* so these connection options need to be part of capabilities
*/
export interface Connection {
/**
* Protocol to use when communicating with the Selenium standalone server (or driver).
*
* @default 'http'
*/
protocol?: string
/**
* Host of your WebDriver server.
*
* @default 'localhost'
*/
hostname?: string
/**
* Port your WebDriver server is on.
*/
port?: number
/**
* Path to WebDriver endpoint or grid server.
*
* @default '/'
*/
path?: string
/**
* Query paramaters that are propagated to the driver server.
*/
queryParams?: {
[name: string]: string
}
/**
* Your cloud service username (only works for [Sauce Labs](https://saucelabs.com),
* [Browserstack](https://www.browserstack.com), [TestingBot](https://testingbot.com) or
* [LambdaTest](https://www.lambdatest.com) accounts). If set, WebdriverIO will
* automatically set connection options for you. If you don't use a cloud provider this
* can be used to authenticate any other WebDriver backend.
*/
user?: string
/**
* Your cloud service access key or secret key (only works for
* [Sauce Labs](https://saucelabs.com), [Browserstack](https://www.browserstack.com),
* [TestingBot](https://testingbot.com) or [LambdaTest](https://www.lambdatest.com) accounts).
* If set, WebdriverIO will automatically set connection options for you. If you don't use
* a cloud provider this can be used to authenticate any other WebDriver backend.
*/
key?: string
}
export interface WebDriver extends Connection {
/**
* Level of logging verbosity.
*
* @default 'info'
*/
logLevel?: WebDriverLogTypes
/**
* Set specific log levels per logger
* use 'silent' level to disable logger
*/
logLevels?: Record<string, WebDriverLogTypes>
/**
* Timeout for any WebDriver request to a driver or grid.
*
* @default 120000
*/
connectionRetryTimeout?: number
/**
* Count of request retries to the Selenium server.
*
* @default 3
*/
connectionRetryCount?: number
/**
* Specify custom headers to pass into every request.
*/
headers?: {
[name: string]: string
}
/**
* Allows you to use a custom http/https/http2 [agent](https://www.npmjs.com/package/got#agent) to make requests.
*
* @default
* ```js
* {
* http: new http.Agent({ keepAlive: true }),
* https: new https.Agent({ keepAlive: true })
* }
* ```
*/
agent?: {
http: http.Agent,
https: https.Agent
}
/**
* Function intercepting [HTTP request options](https://github.com/sindresorhus/got#options) before a WebDriver request is made.
*/
transformRequest?: (requestOptions: RequestLibOptions) => RequestLibOptions
/**
* Function intercepting HTTP response objects after a WebDriver response has arrived.
*/
transformResponse?: (response: RequestLibResponse, requestOptions: RequestLibOptions) => RequestLibResponse
/**
* Appium direct connect options (see: https://appiumpro.com/editions/86-connecting-directly-to-appium-hosts-in-distributed-environments)
*/
enableDirectConnect?: boolean;
/**
* Whether it requires SSL certificates to be valid in HTTP/s requests
* for an environment which cannot get process environment well.
*
* @default true
*/
strictSSL?: boolean
/**
* Directory to store all testrunner log files (including reporter logs and `wdio` logs).
* If not set, all logs are streamed to `stdout`. Since most reporters are made to log to
* `stdout`, it is recommended to only use this option for specific reporters where it
* makes more sense to push report into a file (like the `junit` reporter, for example).
*
* When running in standalone mode, the only log generated by WebdriverIO will be
* the `wdio` log.
*/
outputDir?: string
/**
* The path to the root of the cache directory. This directory is used to store all drivers that are downloaded
* when attempting to start a session.
*/
cacheDir?: string
/**
* Custom webdriver request agent
*/
customWdRequestAgent?: CustomWdRequestAgent
}
export type SauceRegions = 'us' | 'eu' | 'us-west-1' | 'us-east-4' | 'eu-central-1' | 'staging'
export interface WebdriverIO extends WebDriver, Pick<Hooks, 'onReload' | 'beforeCommand' | 'afterCommand'> {
/**
* Define the underlying driver package that executes the WebDriver commands.
* @default 'webdriver'
*/
automationProtocol?: string
/**
* If running on Sauce Labs, you can choose to run tests between different data centers:
* US or EU. To change your region to EU, add region: 'eu' to your config.
*/
region?: SauceRegions
/**
* Shorten url command calls by setting a base URL.
*/
baseUrl?: string
/**
* Default timeout for all `waitFor*` commands. (Note the lowercase f in the option name.)
* This timeout only affects commands starting with `waitFor*` and their default wait time.
* @default 5000
*/
waitforTimeout?: number
/**
* Default interval for all `waitFor*` commands to check if an expected state (e.g.,
* visibility) has been changed.
*/
waitforInterval?: number
}
export interface Testrunner extends Hooks, WebdriverIO, WebdriverIO.HookFunctionExtension {
/**
* Type of runner
* - local: every spec file group is spawned in its own local process
* running an independant browser session
* - browser: all spec files are run within the browser
*/
runner?: 'local' | 'browser' | ['browser', WebdriverIO.BrowserRunnerOptions] | ['local', never]
/**
* Project root directory path.
*/
rootDir?: string
/**
* Define specs for test execution. You can either specify a glob
* pattern to match multiple files at once or wrap a glob or set of
* paths into an array to run them within a single worker process.
*/
specs?: (string | string[])[]
/**
* Exclude specs from test execution.
*/
exclude?: string[]
/**
* An object describing various of suites, which you can then specify
* with the --suite option on the wdio CLI.
*/
suites?: Record<string, (string |string[])[] | string[][]>
/**
* Maximum number of total parallel running workers.
*/
maxInstances?: number
/**
* Maximum number of total parallel running workers per capability.
*/
maxInstancesPerCapability?: number
/**
* Inserts WebdriverIO's globals (e.g. `browser`, `$` and `$$`) into the
* global environment. If you set to `false`, you should import from
* `@wdio/globals`, e.g.:
*
* ```ts
* import { browser, $, $$, expect } from '@wdio/globals'
* ```
*
* Note: WebdriverIO doesn't handle injection of test framework specific
* globals.
*
* @default true
*/
injectGlobals?: boolean
/**
* If you want your test run to stop after a specific number of test failures, use bail.
* (It defaults to 0, which runs all tests no matter what.) Note: Please be aware that
* when using a third party test runner (such as Mocha), additional configuration might
* be required.
*/
bail?: number
/**
* Set to true if you want to update your snapshots.
*/
updateSnapshots?: 'all' | 'new' | 'none'
/**
* Overrides default snapshot path. For example, to store snapshots next to test files.
* @default __snapshots__ stores snapshot files in __snapshots__ directory next to the test file.
*/
resolveSnapshotPath?: (testPath: string, snapExtension: string) => string
/**
* The number of retry attempts for an entire specfile when it fails as a whole.
*/
specFileRetries?: number
/**
* Delay in seconds between the spec file retry attempts
*/
specFileRetriesDelay?: number
/**
* Whether or not retried spec files should be retried immediately or deferred to the end of the queue
*
* @default true
*/
specFileRetriesDeferred?: boolean
/**
* Choose the log output view.
* If set to "false" logs from different test files will be printed in real-time.
* Please note that this may result in the mixing of log outputs from different Test Specs when running in parallel.
* If set to "true" log outputs will be grouped by test files and printed only when the test is completed.
* By default, it is set to "false" so logs are printed in real-time.
*
* @default false
*/
groupLogsByTestSpec?: boolean,
/**
* Services take over a specific job you don't want to take care of. They enhance
* your test setup with almost no effort.
*/
services?: ServiceEntry[]
/**
* Defines the test framework to be used by the WDIO testrunner.
*/
framework?: string
/**
* List of reporters to use. A reporter can be either a string, or an array of
* `['reporterName', { <reporter options> }]` where the first element is a string
* with the reporter name and the second element an object with reporter options.
*/
reporters?: ReporterEntry[]
/**
* Determines in which interval the reporter should check if they are synchronised
* if they report their logs asynchronously (e.g. if logs are streamed to a 3rd
* party vendor).
*/
reporterSyncInterval?: number
/**
* Determines the maximum time reporters have to finish uploading all their logs
* until an error is being thrown by the testrunner.
*/
reporterSyncTimeout?: number
/**
* Node arguments to specify when launching child processes.
*/
execArgv?: string[]
/**
* A set of environment variables to be injected into the worker process.
*/
runnerEnv?: Record<string, string>
/**
* Files to watch when running `wdio` with the `--watch` flag.
*/
filesToWatch?: string[]
/**
* List of cucumber features with line numbers (when using [cucumber framework](https://webdriver.io/docs/frameworks.html#using-cucumber)).
* @default []
*/
cucumberFeaturesWithLineNumbers?: string[]
/**
* flags
*/
watch?: boolean
/**
* Shard tests and execute only the selected shard. Specify in the one-based form like `{ total: 5, current: 2 }`.
*/
shard?: ShardOptions
/**
* framework options
*/
mochaOpts?: WebdriverIO.MochaOpts
jasmineOpts?: WebdriverIO.JasmineOpts
cucumberOpts?: WebdriverIO.CucumberOpts
/**
* TSX custom TSConfig path
*/
tsConfigPath?: string
}
export interface TSConfigPathsOptions {
baseUrl: string
paths: Record<string, string[]>
mainFields?: string[]
addMatchAll?: boolean
}
export type Definition<T> = {
[k in keyof T]: {
type: 'string' | 'number' | 'object' | 'boolean' | 'function'
default?: T[k]
required?: boolean
validate?: (option: T[k], keysToKeep?: (keyof T)[]) => void
match?: RegExp
}
}
export interface RunnerStart {
cid: string
specs: string[]
config: Testrunner
isMultiremote: boolean
instanceOptions: Record<string, WebdriverIO>
sessionId: string
capabilities: WebdriverIO.Capabilities
retry?: number
failures?: number
retries?: number
}
export interface RunnerEnd {
failures: number
cid: string
retries: number
error?: string
}