codeceptjs 4.0.0-beta.2 → 4.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +2 -2
  2. package/bin/codecept.js +84 -81
  3. package/lib/actor.js +13 -13
  4. package/lib/ai.js +10 -13
  5. package/lib/assert/empty.js +20 -21
  6. package/lib/assert/equal.js +37 -39
  7. package/lib/assert/error.js +14 -14
  8. package/lib/assert/include.js +46 -47
  9. package/lib/assert/throws.js +13 -11
  10. package/lib/assert/truth.js +19 -22
  11. package/lib/assert.js +4 -2
  12. package/lib/cli.js +56 -49
  13. package/lib/codecept.js +145 -155
  14. package/lib/colorUtils.js +3 -3
  15. package/lib/command/configMigrate.js +58 -52
  16. package/lib/command/definitions.js +88 -89
  17. package/lib/command/dryRun.js +79 -81
  18. package/lib/command/generate.js +197 -188
  19. package/lib/command/gherkin/init.js +27 -16
  20. package/lib/command/gherkin/snippets.js +21 -21
  21. package/lib/command/gherkin/steps.js +8 -8
  22. package/lib/command/info.js +40 -38
  23. package/lib/command/init.js +290 -288
  24. package/lib/command/interactive.js +32 -32
  25. package/lib/command/list.js +26 -26
  26. package/lib/command/run-multiple/chunk.js +5 -5
  27. package/lib/command/run-multiple/collection.js +3 -3
  28. package/lib/command/run-multiple/run.js +6 -2
  29. package/lib/command/run-multiple.js +113 -93
  30. package/lib/command/run-rerun.js +20 -25
  31. package/lib/command/run-workers.js +64 -66
  32. package/lib/command/run.js +26 -29
  33. package/lib/command/utils.js +80 -65
  34. package/lib/command/workers/runTests.js +11 -12
  35. package/lib/config.js +10 -9
  36. package/lib/container.js +40 -48
  37. package/lib/data/context.js +60 -59
  38. package/lib/data/dataScenarioConfig.js +47 -47
  39. package/lib/data/dataTableArgument.js +29 -29
  40. package/lib/data/table.js +26 -20
  41. package/lib/event.js +163 -167
  42. package/lib/heal.js +14 -18
  43. package/lib/helper/AI.js +130 -41
  44. package/lib/helper/ApiDataFactory.js +74 -70
  45. package/lib/helper/Appium.js +416 -388
  46. package/lib/helper/ExpectHelper.js +40 -48
  47. package/lib/helper/FileSystem.js +80 -79
  48. package/lib/helper/GraphQL.js +44 -43
  49. package/lib/helper/GraphQLDataFactory.js +51 -51
  50. package/lib/helper/JSONResponse.js +65 -62
  51. package/lib/helper/Mochawesome.js +28 -28
  52. package/lib/helper/Nightmare.js +664 -571
  53. package/lib/helper/Playwright.js +1367 -1222
  54. package/lib/helper/Protractor.js +663 -635
  55. package/lib/helper/Puppeteer.js +1232 -1132
  56. package/lib/helper/REST.js +183 -68
  57. package/lib/helper/SoftExpectHelper.js +2 -2
  58. package/lib/helper/TestCafe.js +490 -486
  59. package/lib/helper/WebDriver.js +1246 -1297
  60. package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
  61. package/lib/helper/errors/ConnectionRefused.js +1 -1
  62. package/lib/helper/errors/ElementAssertion.js +2 -2
  63. package/lib/helper/errors/ElementNotFound.js +2 -2
  64. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
  65. package/lib/helper/extras/Console.js +1 -1
  66. package/lib/helper/extras/PlaywrightPropEngine.js +4 -4
  67. package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
  68. package/lib/helper/extras/PlaywrightRestartOpts.js +21 -18
  69. package/lib/helper/extras/Popup.js +1 -1
  70. package/lib/helper/extras/React.js +3 -3
  71. package/lib/helper/network/actions.js +14 -7
  72. package/lib/helper/network/utils.js +4 -3
  73. package/lib/helper/scripts/blurElement.js +1 -1
  74. package/lib/helper/scripts/focusElement.js +1 -1
  75. package/lib/helper/scripts/highlightElement.js +1 -1
  76. package/lib/helper/scripts/isElementClickable.js +1 -1
  77. package/lib/helper/testcafe/testControllerHolder.js +1 -1
  78. package/lib/helper/testcafe/testcafe-utils.js +7 -8
  79. package/lib/helper.js +1 -3
  80. package/lib/history.js +6 -5
  81. package/lib/hooks.js +6 -6
  82. package/lib/html.js +7 -7
  83. package/lib/index.js +25 -41
  84. package/lib/interfaces/bdd.js +47 -64
  85. package/lib/interfaces/featureConfig.js +19 -19
  86. package/lib/interfaces/gherkin.js +124 -118
  87. package/lib/interfaces/scenarioConfig.js +29 -29
  88. package/lib/listener/artifacts.js +9 -9
  89. package/lib/listener/config.js +24 -24
  90. package/lib/listener/exit.js +12 -12
  91. package/lib/listener/helpers.js +42 -42
  92. package/lib/listener/mocha.js +11 -11
  93. package/lib/listener/retry.js +32 -30
  94. package/lib/listener/steps.js +50 -53
  95. package/lib/listener/timeout.js +54 -54
  96. package/lib/locator.js +7 -11
  97. package/lib/mochaFactory.js +18 -15
  98. package/lib/output.js +19 -15
  99. package/lib/parser.js +15 -12
  100. package/lib/pause.js +45 -38
  101. package/lib/plugin/allure.js +15 -15
  102. package/lib/plugin/autoDelay.js +29 -37
  103. package/lib/plugin/autoLogin.js +70 -65
  104. package/lib/plugin/commentStep.js +18 -18
  105. package/lib/plugin/coverage.js +112 -67
  106. package/lib/plugin/customLocator.js +21 -20
  107. package/lib/plugin/debugErrors.js +24 -24
  108. package/lib/plugin/eachElement.js +38 -38
  109. package/lib/plugin/fakerTransform.js +6 -6
  110. package/lib/plugin/heal.js +67 -108
  111. package/lib/plugin/pauseOnFail.js +11 -11
  112. package/lib/plugin/retryFailedStep.js +32 -39
  113. package/lib/plugin/retryTo.js +46 -40
  114. package/lib/plugin/screenshotOnFail.js +109 -87
  115. package/lib/plugin/selenoid.js +131 -118
  116. package/lib/plugin/standardActingHelpers.js +2 -8
  117. package/lib/plugin/stepByStepReport.js +110 -91
  118. package/lib/plugin/stepTimeout.js +24 -23
  119. package/lib/plugin/subtitles.js +34 -35
  120. package/lib/plugin/tryTo.js +40 -30
  121. package/lib/plugin/wdio.js +78 -75
  122. package/lib/recorder.js +14 -17
  123. package/lib/rerun.js +11 -10
  124. package/lib/scenario.js +25 -23
  125. package/lib/secret.js +4 -3
  126. package/lib/session.js +10 -10
  127. package/lib/step.js +12 -9
  128. package/lib/store.js +2 -3
  129. package/lib/transform.js +1 -1
  130. package/lib/translation.js +7 -8
  131. package/lib/ui.js +12 -14
  132. package/lib/utils.js +70 -72
  133. package/lib/within.js +10 -10
  134. package/lib/workerStorage.js +27 -25
  135. package/lib/workers.js +29 -33
  136. package/package.json +67 -68
  137. package/translations/de-DE.js +2 -1
  138. package/translations/fr-FR.js +2 -2
  139. package/translations/index.js +9 -13
  140. package/translations/it-IT.js +1 -1
  141. package/translations/ja-JP.js +1 -1
  142. package/translations/pl-PL.js +1 -1
  143. package/translations/pt-BR.js +1 -1
  144. package/translations/ru-RU.js +1 -1
  145. package/translations/zh-CN.js +1 -1
  146. package/translations/zh-TW.js +1 -1
  147. package/typings/index.d.ts +423 -65
  148. package/typings/promiseBasedTypes.d.ts +41 -172
  149. package/typings/types.d.ts +43 -178
  150. package/lib/dirname.js +0 -5
  151. package/lib/helper/Expect.js +0 -425
  152. package/lib/helper/MockServer.js +0 -223
@@ -7,125 +7,435 @@
7
7
  /// <reference types="playwright" />
8
8
 
9
9
  declare namespace CodeceptJS {
10
- // Utility Types
11
- type WithTranslation<T> = T & import("./utils").Translate<T, Translation.Actions>;
10
+ type WithTranslation<T> = T &
11
+ // @ts-ignore
12
+ import("./utils").Translate<T, Translation.Actions>;
12
13
 
13
- // Cookie Type
14
14
  type Cookie = {
15
15
  name: string;
16
16
  value: string | boolean;
17
- domain?: string;
18
- path?: string;
17
+ domain?: string,
18
+ path?: string,
19
19
  };
20
20
 
21
- // Retry Configuration
22
21
  type RetryConfig = {
22
+ /** Filter tests by string or regexp pattern */
23
23
  grep?: string | RegExp;
24
+ /** Number of times to repeat scenarios of a Feature */
24
25
  Feature?: number;
26
+ /** Number of times to repeat scenarios */
25
27
  Scenario?: number;
28
+ /** Number of times to repeat Before hook */
26
29
  Before?: number;
30
+ /** Number of times to repeat After hook */
27
31
  After?: number;
32
+ /** Number of times to repeat BeforeSuite hook */
28
33
  BeforeSuite?: number;
34
+ /** Number of times to repeat AfterSuite hook */
29
35
  AfterSuite?: number;
30
36
  };
31
37
 
32
- // Timeout Configuration
33
38
  type TimeoutConfig = {
39
+ /** Filter tests by string or regexp pattern */
34
40
  grep: string | RegExp;
41
+ /** Set timeout for a scenarios of a Feature */
35
42
  Feature: number;
43
+ /** Set timeout for scenarios */
36
44
  Scenario: number;
37
45
  };
38
46
 
39
- // AI Configuration
40
47
  type AiPrompt = {
41
48
  role: string;
42
49
  content: string;
43
- };
50
+ }
44
51
 
45
52
  type AiConfig = {
46
- request: (messages: any) => Promise<string>;
53
+ /** request function to send prompts to AI provider */
54
+ request: (messages: any) => Promise<string>,
55
+
56
+ /** custom prompts */
47
57
  prompts?: {
58
+ /** Returns prompt to write CodeceptJS steps inside pause mode */
48
59
  writeStep?: (html: string, input: string) => Array<AiPrompt>;
60
+ /** Returns prompt to heal step when test fails on CI if healing is on */
49
61
  healStep?: (html: string, object) => Array<AiPrompt>;
50
- generatePageObject?: (
51
- html: string,
52
- extraPrompt?: string,
53
- rootLocator?: string
54
- ) => Array<AiPrompt>;
55
- };
56
- maxTokens?: number;
62
+ /** Returns prompt to generate page object inside pause mode */
63
+ generatePageObject?: (html: string, extraPrompt?: string, rootLocator?: string) => Array<AiPrompt>;
64
+ },
65
+
66
+ /** max tokens to use */
67
+ maxTokens?: number,
68
+
69
+
70
+ /** configuration for processing HTML for GPT */
57
71
  html?: {
58
- maxLength?: number;
59
- simplify?: boolean;
60
- minify?: boolean;
61
- interactiveElements?: Array<string>;
62
- textElements?: Array<string>;
63
- allowedAttrs?: Array<string>;
64
- allowedRoles?: Array<string>;
65
- };
66
- };
72
+ /** max size of HTML to be sent to OpenAI to avoid token limit */
73
+ maxLength?: number,
74
+ /** should HTML be changed by removing non-interactive elements */
75
+ simplify?: boolean,
76
+ /** should HTML be minified before sending */
77
+ minify?: boolean,
78
+ interactiveElements?: Array<string>,
79
+ textElements?: Array<string>,
80
+ allowedAttrs?: Array<string>,
81
+ allowedRoles?: Array<string>,
82
+ }
83
+ }
67
84
 
68
- // Main Configuration
69
85
  type MainConfig = {
86
+ /** Pattern to locate CodeceptJS tests.
87
+ * Allows to enter glob pattern or an Array<string> of patterns to match tests / test file names.
88
+ *
89
+ * For tests in JavaScript:
90
+ *
91
+ * ```js
92
+ * tests: 'tests/**.test.js'
93
+ * ```
94
+ * For tests in TypeScript:
95
+ *
96
+ * ```js
97
+ * tests: 'tests/**.test.ts'
98
+ * ```
99
+ */
70
100
  tests: string;
101
+ /**
102
+ * Where to store failure screenshots, artifacts, etc
103
+ *
104
+ * ```js
105
+ * output: './output'
106
+ * ```
107
+ */
71
108
  output: string;
109
+ /**
110
+ * empty output folder for next run
111
+ *
112
+ * ```js
113
+ * emptyOutputFolder: true
114
+ * ```
115
+ */
72
116
  emptyOutputFolder?: boolean;
117
+ /**
118
+ * mask sensitive data in output logs
119
+ *
120
+ * ```js
121
+ * maskSensitiveData: true
122
+ * ```
123
+ */
124
+ maskSensitiveData?: boolean;
125
+ /**
126
+ * Pattern to filter tests by name.
127
+ * This option is useful if you plan to use multiple configs for different environments.
128
+ *
129
+ * To execute only tests with @firefox tag
130
+ *
131
+ * ```js
132
+ * grep: '@firefox'
133
+ * ```
134
+ */
73
135
  grep?: string;
136
+ /**
137
+ * Enable and configure helpers:
138
+ *
139
+ * ```js
140
+ * helpers: {
141
+ * Playwright: {
142
+ * url: 'https://mysite.com',
143
+ * browser: 'firefox'
144
+ * }
145
+ * }
146
+ * ```
147
+ */
74
148
  helpers?: {
149
+ /**
150
+ * Run web tests controlling browsers via Playwright engine.
151
+ *
152
+ * https://codecept.io/helpers/playwright
153
+ *
154
+ * Available commands:
155
+ * ```js
156
+ * I.amOnPage('/');
157
+ * I.click('Open');
158
+ * I.see('Welcome');
159
+ * ```
160
+ */
75
161
  Playwright?: PlaywrightConfig;
162
+ /**
163
+ * Run web tests controlling browsers via Puppeteer engine.
164
+ *
165
+ * https://codecept.io/helpers/puppeteer
166
+ *
167
+ * Available commands:
168
+ * ```js
169
+ * I.amOnPage('/');
170
+ * I.click('Open');
171
+ * I.see('Welcome');
172
+ * ```
173
+ */
76
174
  Puppeteer?: PuppeteerConfig;
175
+
176
+ /**
177
+ * Run web tests controlling browsers via WebDriver engine.
178
+ *
179
+ * Available commands:
180
+ * ```js
181
+ * I.amOnPage('/');
182
+ * I.click('Open');
183
+ * I.see('Welcome');
184
+ * ```
185
+ *
186
+ * https://codecept.io/helpers/webdriver
187
+ */
77
188
  WebDriver?: WebDriverConfig;
189
+ /**
190
+ * Execute REST API requests for API testing or to assist web testing.
191
+ *
192
+ * https://codecept.io/helpers/REST
193
+ *
194
+ * Available commands:
195
+ * ```js
196
+ * I.sendGetRequest('/');
197
+ * ```
198
+ */
78
199
  REST?: RESTConfig;
200
+
201
+ /**
202
+ * Use JSON assertions for API testing.
203
+ * Can be paired with REST or GraphQL helpers.
204
+ *
205
+ * https://codecept.io/helpers/JSONResponse
206
+ *
207
+ * Available commands:
208
+ * ```js
209
+ * I.seeResponseContainsJson({ user: { email: 'jon@doe.com' } });
210
+ * ```
211
+ */
79
212
  JSONResponse?: any;
213
+
214
+ /** Enable AI features for development purposes */
80
215
  AI?: any;
216
+
81
217
  [key: string]: any;
82
- };
218
+ },
219
+ /**
220
+ * Enable CodeceptJS plugins.
221
+ *
222
+ * https://codecept.io/plugins/
223
+ *
224
+ * Plugins listen to test events and extend functionality of CodeceptJS.
225
+ *
226
+ * Example:
227
+ *
228
+ * ```js
229
+ * plugins: {
230
+ * autoDelay: {
231
+ * enabled: true
232
+ * }
233
+ }
234
+ * ```
235
+ */
83
236
  plugins?: any;
237
+ /**
238
+ * Include page objects to access them via dependency injection
239
+ *
240
+ * ```js
241
+ * I: "./custom_steps.js",
242
+ * loginPage: "./pages/Login.js",
243
+ * User: "./pages/User.js",
244
+ * ```
245
+ * Configured modules can be injected by name in a Scenario:
246
+ *
247
+ * ```js
248
+ * Scenario('test', { I, loginPage, User })
249
+ * ```
250
+ */
84
251
  include?: any;
252
+ /**
253
+ * Set default tests timeout in seconds.
254
+ * Tests will be killed on no response after timeout.
255
+ *
256
+ * ```js
257
+ * timeout: 20,
258
+ * ```
259
+ *
260
+ * Can be customized to use different timeouts for a subset of tests:
261
+ *
262
+ * ```js
263
+ * timeout: [
264
+ * 10,
265
+ * {
266
+ * grep: '@slow',
267
+ * Scenario: 20
268
+ * }
269
+ * ]
270
+ * ```
271
+ */
85
272
  timeout?: number | Array<TimeoutConfig> | TimeoutConfig;
273
+
274
+ /**
275
+ * Configure retry strategy for tests
276
+ *
277
+ * To retry all tests 3 times:
278
+ *
279
+ * ```js
280
+ * retry: 3
281
+ * ```
282
+ *
283
+ * To retry only Before hook 3 times:
284
+ *
285
+ * ```js
286
+ * retry: {
287
+ * Before: 3
288
+ * }
289
+ * ```
290
+ *
291
+ * To retry tests marked as flaky 3 times, other 1 time:
292
+ *
293
+ * ```js
294
+ * retry: [
295
+ * {
296
+ * Scenario: 1,
297
+ * Before: 1
298
+ * },
299
+ * {
300
+ * grep: '@flaky',
301
+ * Scenario: 3
302
+ * Before: 3
303
+ * }
304
+ * ]
305
+ * ```
306
+ */
86
307
  retry?: number | Array<RetryConfig> | RetryConfig;
308
+
309
+
310
+ /** Disable registering global functions (Before, Scenario, etc). Not recommended */
87
311
  noGlobals?: boolean;
312
+ /**
313
+ * [Mocha test runner options](https://mochajs.org/#configuring-mocha-nodejs), additional [reporters](https://codecept.io/reports/#xml) can be configured here.
314
+ *
315
+ * Example:
316
+ *
317
+ * ```js
318
+ * mocha: {
319
+ * "mocha-junit-reporter": {
320
+ * stdout: "./output/console.log",
321
+ * options: {
322
+ * mochaFile: "./output/result.xml",
323
+ * attachments: true //add screenshot for a failed test
324
+ * }
325
+ * }
326
+ * }
327
+ * ```
328
+ */
88
329
  mocha?: any;
330
+ /**
331
+ * [Execute code before](https://codecept.io/bootstrap/) tests are run.
332
+ *
333
+ * Can be either JS module file or async function:
334
+ *
335
+ * ```js
336
+ * bootstrap: async () => server.launch(),
337
+ * ```
338
+ * or
339
+ * ```js
340
+ * bootstrap: 'bootstrap.js',
341
+ * ```
342
+ */
89
343
  bootstrap?: (() => Promise<void>) | boolean | string;
344
+ /**
345
+ * [Execute code after tests](https://codecept.io/bootstrap/) finished.
346
+ *
347
+ * Can be either JS module file or async function:
348
+ *
349
+ * ```js
350
+ * teardown: async () => server.stop(),
351
+ * ```
352
+ * or
353
+ * ```js
354
+ * teardown: 'teardown.js',
355
+ * ```
356
+ */
90
357
  teardown?: (() => Promise<void>) | boolean | string;
358
+ /**
359
+ * [Execute code before launching tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall)
360
+ *
361
+ */
91
362
  bootstrapAll?: (() => Promise<void>) | boolean | string;
363
+ /**
364
+ * [Execute JS code after finishing tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall)
365
+ */
92
366
  teardownAll?: (() => Promise<void>) | boolean | string;
367
+
368
+ /** Enable [localized test commands](https://codecept.io/translation/) */
93
369
  translation?: string;
370
+
371
+ /** Additional vocabularies for [localication](https://codecept.io/translation/) */
94
372
  vocabularies?: Array<string>;
373
+
374
+ /**
375
+ * [Require additional JS modules](https://codecept.io/configuration/#require)
376
+ *
377
+ * Example:
378
+ * ```
379
+ * require: ["should"]
380
+ * ```
381
+ */
95
382
  require?: Array<string>;
383
+
384
+ /**
385
+ * Enable [BDD features](https://codecept.io/bdd/#configuration).
386
+ *
387
+ * Sample configuration:
388
+ * ```js
389
+ * gherkin: {
390
+ * features: "./features/*.feature",
391
+ * steps: ["./step_definitions/steps.js"]
392
+ * }
393
+ * ```
394
+ */
96
395
  gherkin?: {
97
- features: string | Array<string>;
98
- steps: string | Array<string>;
396
+ /** load feature files by pattern. Multiple patterns can be specified as array */
397
+ features: string | Array<string>,
398
+ /** load step definitions from JS files */
399
+ steps: string | Array<string>
99
400
  };
100
- ai?: AiConfig;
401
+
402
+ /**
403
+ * [AI](https://codecept.io/ai/) features configuration.
404
+ */
405
+ ai?: AiConfig,
406
+
407
+ /**
408
+ * Enable full promise-based helper methods for [TypeScript](https://codecept.io/typescript/) project.
409
+ * If true, all helper methods are typed as asynchronous;
410
+ * Otherwise, it remains as it works in versions prior to 3.3.6
411
+ */
101
412
  fullPromiseBased?: boolean;
413
+
102
414
  [key: string]: any;
103
415
  };
104
416
 
105
- // Mocking
106
417
  type MockRequest = {
107
- method: 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | string;
418
+ method: 'GET'|'PUT'|'POST'|'PATCH'|'DELETE'|string;
108
419
  path: string;
109
420
  queryParams?: object;
110
- };
421
+ }
111
422
 
112
423
  type MockResponse = {
113
424
  status: number;
114
425
  body?: object;
115
- };
426
+ }
116
427
 
117
428
  type MockInteraction = {
118
429
  request: MockRequest;
119
430
  response: MockResponse;
120
- };
431
+ }
121
432
 
122
- // Page Scroll
123
433
  interface PageScrollPosition {
124
434
  x: number;
125
435
  y: number;
126
436
  }
127
437
 
128
- // Actors and Support
438
+ // Could get extended by user generated typings
129
439
  interface Methods extends ActorStatic {}
130
440
  interface I {}
131
441
  interface IHook {}
@@ -133,11 +443,24 @@ declare namespace CodeceptJS {
133
443
  interface IFeature {
134
444
  (title: string): FeatureConfig;
135
445
  }
446
+ interface CallbackOrder extends Array<any> {}
136
447
  interface SupportObject {
137
448
  I: CodeceptJS.I;
138
449
  }
450
+ namespace Translation {
451
+ interface Actions {}
452
+ }
453
+
454
+ // Extending JSDoc generated typings
455
+ interface Step {
456
+ isMetaStep(): this is MetaStep;
457
+ }
458
+
459
+ // Types who are not be defined by JSDoc
460
+ type actor = <T extends { [action: string]: (...args: any[]) => void }>(
461
+ customSteps?: T & ThisType<WithTranslation<Methods & T>>
462
+ ) => WithTranslation<Methods & T>;
139
463
 
140
- // Locator Types
141
464
  type ILocator =
142
465
  | { id: string }
143
466
  | { xpath: string }
@@ -146,38 +469,41 @@ declare namespace CodeceptJS {
146
469
  | { frame: string }
147
470
  | { android: string }
148
471
  | { ios: string }
472
+ | { android: string; ios: string }
149
473
  | { react: string }
150
474
  | { vue: string }
151
475
  | { shadow: string[] }
152
476
  | { custom: string }
153
477
  | { pw: string };
154
-
155
- type LocatorOrString = string | ILocator | OtherLocators | CustomLocators[keyof CustomLocators];
478
+ interface CustomLocators {}
479
+ interface OtherLocators { props?: object }
480
+ type LocatorOrString =
481
+ | string
482
+ | ILocator
483
+ | Locator
484
+ | OtherLocators
485
+ | CustomLocators[keyof CustomLocators];
156
486
 
157
487
  type StringOrSecret = string | CodeceptJS.Secret;
158
488
 
159
- // Hook and Scenario Callbacks
160
489
  interface HookCallback {
161
490
  (args: SupportObject): void | Promise<void>;
162
491
  }
163
-
164
492
  interface Scenario extends IScenario {
165
493
  only: IScenario;
166
494
  skip: IScenario;
167
495
  todo: IScenario;
168
496
  }
169
-
170
497
  interface Feature extends IFeature {
171
498
  skip: IFeature;
172
499
  }
173
-
174
500
  interface IData {
175
501
  Scenario: IScenario;
176
502
  only: { Scenario: IScenario };
177
503
  }
178
504
 
179
- // Scenario Interface
180
505
  interface IScenario {
506
+ // Scenario.todo can be called only with a title.
181
507
  (title: string, callback?: HookCallback): ScenarioConfig;
182
508
  (
183
509
  title: string,
@@ -185,39 +511,44 @@ declare namespace CodeceptJS {
185
511
  callback: HookCallback
186
512
  ): ScenarioConfig;
187
513
  }
188
-
189
514
  interface IHook {
190
515
  (callback: HookCallback): void;
191
516
  }
192
517
 
193
- // Global Utilities
194
518
  interface Globals {
195
519
  codeceptjs: typeof codeceptjs;
196
520
  }
197
521
 
198
- // BDD Parameter Types
199
522
  interface IParameterTypeDefinition<T> {
200
- name: string;
201
- regexp: readonly RegExp[] | readonly string[] | RegExp | string;
202
- transformer: (...match: string[]) => T;
203
- useForSnippets?: boolean;
204
- preferForRegexpMatch?: boolean;
523
+ name: string
524
+ regexp: readonly RegExp[] | readonly string[] | RegExp | string
525
+ transformer: (...match: string[]) => T
526
+ useForSnippets?: boolean
527
+ preferForRegexpMatch?: boolean
205
528
  }
206
529
  }
207
530
 
208
531
  // Globals
209
532
  declare const codecept_dir: string;
210
533
  declare const output_dir: string;
211
- declare function tryTo<T>(...fn: unknown[]): Promise<T>;
212
- declare function retryTo<T>(...fn: unknown[]): Promise<T>;
534
+ declare function tryTo(...fn): Promise<boolean>;
535
+ declare function retryTo(...fn): Promise<null>;
213
536
 
214
537
  declare const actor: CodeceptJS.actor;
538
+ declare const codecept_actor: CodeceptJS.actor;
215
539
  declare const Helper: typeof CodeceptJS.Helper;
540
+ declare const codecept_helper: typeof CodeceptJS.Helper;
216
541
  declare const pause: typeof CodeceptJS.pause;
217
542
  declare const within: typeof CodeceptJS.within;
218
543
  declare const session: typeof CodeceptJS.session;
219
544
  declare const DataTable: typeof CodeceptJS.DataTable;
545
+ declare const DataTableArgument: typeof CodeceptJS.DataTableArgument;
546
+ declare const codeceptjs: typeof CodeceptJS.index;
220
547
  declare const locate: typeof CodeceptJS.Locator.build;
548
+ declare function inject(): CodeceptJS.SupportObject;
549
+ declare function inject<T extends keyof CodeceptJS.SupportObject>(
550
+ name: T
551
+ ): CodeceptJS.SupportObject[T];
221
552
  declare const secret: typeof CodeceptJS.Secret.secret;
222
553
 
223
554
  // BDD
@@ -225,37 +556,58 @@ declare const Given: typeof CodeceptJS.addStep;
225
556
  declare const When: typeof CodeceptJS.addStep;
226
557
  declare const Then: typeof CodeceptJS.addStep;
227
558
 
559
+ declare const Feature: typeof CodeceptJS.Feature;
560
+ declare const Scenario: CodeceptJS.Scenario;
561
+ declare const xScenario: CodeceptJS.IScenario;
562
+ declare const xFeature: CodeceptJS.IFeature;
563
+ declare function Data(data: any): CodeceptJS.IData;
564
+ declare function xData(data: any): CodeceptJS.IData;
565
+ declare function DefineParameterType(options: CodeceptJS.IParameterTypeDefinition<any>): void
566
+
228
567
  // Hooks
229
568
  declare const BeforeSuite: CodeceptJS.IHook;
230
569
  declare const AfterSuite: CodeceptJS.IHook;
570
+ declare const Background: CodeceptJS.IHook;
231
571
  declare const Before: CodeceptJS.IHook;
232
572
  declare const After: CodeceptJS.IHook;
233
573
 
234
- // Process Interface
574
+ // Plugins
575
+ declare const __: any
576
+
577
+ interface Window {
578
+ resq: any;
579
+ }
580
+
235
581
  declare namespace NodeJS {
236
582
  interface Process {
237
- profile?: string;
238
- env?: {
239
- [key: string]: string | undefined;
240
- };
583
+ profile: string;
241
584
  }
242
585
 
243
586
  interface Global extends CodeceptJS.Globals {
244
587
  codecept_dir: typeof codecept_dir;
245
588
  output_dir: typeof output_dir;
589
+
246
590
  actor: typeof actor;
591
+ codecept_actor: typeof codecept_actor;
247
592
  Helper: typeof Helper;
593
+ codecept_helper: typeof codecept_helper;
248
594
  pause: typeof pause;
249
595
  within: typeof within;
250
596
  session: typeof session;
251
597
  DataTable: typeof DataTable;
598
+ DataTableArgument: typeof DataTableArgument;
252
599
  locate: typeof locate;
600
+ inject: typeof inject;
253
601
  secret: typeof secret;
602
+ // plugins
254
603
  tryTo: typeof tryTo;
255
604
  retryTo: typeof retryTo;
605
+
606
+ // BDD
256
607
  Given: typeof Given;
257
608
  When: typeof When;
258
609
  Then: typeof Then;
610
+ DefineParameterType: typeof DefineParameterType
259
611
  }
260
612
  }
261
613
 
@@ -263,20 +615,26 @@ declare namespace Mocha {
263
615
  interface MochaGlobals {
264
616
  Feature: typeof Feature;
265
617
  Scenario: typeof Scenario;
618
+ xFeature: typeof xFeature;
619
+ xScenario: typeof xScenario;
620
+ Data: typeof Data;
621
+ xData: typeof xData;
266
622
  BeforeSuite: typeof BeforeSuite;
267
623
  AfterSuite: typeof AfterSuite;
624
+ Background: typeof Background;
268
625
  Before: typeof Before;
269
626
  After: typeof After;
270
627
  }
271
628
 
272
629
  interface Suite extends SuiteRunnable {
273
- tags?: any[];
274
- feature?: any;
630
+ tags: any[];
631
+ comment: string;
632
+ feature: any;
275
633
  }
276
634
 
277
635
  interface Test extends Runnable {
278
- artifacts?: [];
279
- tags?: any[];
636
+ artifacts: [],
637
+ tags: any[];
280
638
  }
281
639
  }
282
640