codeceptjs 4.0.0-beta.1 → 4.0.0-beta.3

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