codeceptjs 3.6.6 → 4.0.0-beta.1

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 +81 -84
  2. package/lib/actor.js +13 -13
  3. package/lib/ai.js +13 -10
  4. package/lib/assert/empty.js +21 -20
  5. package/lib/assert/equal.js +39 -37
  6. package/lib/assert/error.js +14 -14
  7. package/lib/assert/include.js +47 -46
  8. package/lib/assert/throws.js +11 -13
  9. package/lib/assert/truth.js +22 -19
  10. package/lib/assert.js +2 -4
  11. package/lib/cli.js +49 -57
  12. package/lib/codecept.js +155 -142
  13. package/lib/colorUtils.js +3 -3
  14. package/lib/command/configMigrate.js +52 -58
  15. package/lib/command/definitions.js +89 -88
  16. package/lib/command/dryRun.js +68 -71
  17. package/lib/command/generate.js +188 -197
  18. package/lib/command/gherkin/init.js +16 -27
  19. package/lib/command/gherkin/snippets.js +20 -20
  20. package/lib/command/gherkin/steps.js +8 -8
  21. package/lib/command/info.js +38 -40
  22. package/lib/command/init.js +288 -290
  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 +2 -6
  28. package/lib/command/run-multiple.js +93 -113
  29. package/lib/command/run-rerun.js +25 -20
  30. package/lib/command/run-workers.js +66 -64
  31. package/lib/command/run.js +29 -26
  32. package/lib/command/utils.js +65 -80
  33. package/lib/command/workers/runTests.js +10 -10
  34. package/lib/config.js +9 -10
  35. package/lib/container.js +48 -40
  36. package/lib/data/context.js +59 -60
  37. package/lib/data/dataScenarioConfig.js +47 -47
  38. package/lib/data/dataTableArgument.js +29 -29
  39. package/lib/data/table.js +20 -26
  40. package/lib/dirname.js +5 -0
  41. package/lib/event.js +167 -163
  42. package/lib/heal.js +17 -13
  43. package/lib/helper/AI.js +41 -130
  44. package/lib/helper/ApiDataFactory.js +69 -73
  45. package/lib/helper/Appium.js +381 -412
  46. package/lib/helper/Expect.js +425 -0
  47. package/lib/helper/ExpectHelper.js +48 -40
  48. package/lib/helper/FileSystem.js +79 -80
  49. package/lib/helper/GraphQL.js +43 -44
  50. package/lib/helper/GraphQLDataFactory.js +50 -50
  51. package/lib/helper/JSONResponse.js +62 -65
  52. package/lib/helper/Mochawesome.js +28 -28
  53. package/lib/helper/MockServer.js +14 -12
  54. package/lib/helper/Nightmare.js +566 -662
  55. package/lib/helper/Playwright.js +1216 -1361
  56. package/lib/helper/Protractor.js +627 -663
  57. package/lib/helper/Puppeteer.js +1128 -1231
  58. package/lib/helper/REST.js +68 -159
  59. package/lib/helper/SoftExpectHelper.js +2 -2
  60. package/lib/helper/TestCafe.js +484 -490
  61. package/lib/helper/WebDriver.js +1156 -1297
  62. package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
  63. package/lib/helper/errors/ConnectionRefused.js +1 -1
  64. package/lib/helper/errors/ElementAssertion.js +2 -2
  65. package/lib/helper/errors/ElementNotFound.js +2 -2
  66. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
  67. package/lib/helper/extras/Console.js +1 -1
  68. package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
  69. package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
  70. package/lib/helper/extras/PlaywrightRestartOpts.js +18 -21
  71. package/lib/helper/extras/Popup.js +1 -1
  72. package/lib/helper/extras/React.js +3 -3
  73. package/lib/helper/network/actions.js +7 -14
  74. package/lib/helper/network/utils.js +2 -3
  75. package/lib/helper/scripts/blurElement.js +1 -1
  76. package/lib/helper/scripts/focusElement.js +1 -1
  77. package/lib/helper/scripts/highlightElement.js +1 -1
  78. package/lib/helper/scripts/isElementClickable.js +1 -1
  79. package/lib/helper/testcafe/testControllerHolder.js +1 -1
  80. package/lib/helper/testcafe/testcafe-utils.js +7 -6
  81. package/lib/helper.js +3 -1
  82. package/lib/history.js +5 -6
  83. package/lib/hooks.js +6 -6
  84. package/lib/html.js +7 -7
  85. package/lib/index.js +41 -25
  86. package/lib/interfaces/bdd.js +64 -47
  87. package/lib/interfaces/featureConfig.js +19 -19
  88. package/lib/interfaces/gherkin.js +118 -124
  89. package/lib/interfaces/scenarioConfig.js +29 -29
  90. package/lib/listener/artifacts.js +9 -9
  91. package/lib/listener/config.js +24 -24
  92. package/lib/listener/exit.js +12 -12
  93. package/lib/listener/helpers.js +42 -42
  94. package/lib/listener/mocha.js +11 -11
  95. package/lib/listener/retry.js +30 -32
  96. package/lib/listener/steps.js +53 -50
  97. package/lib/listener/timeout.js +54 -54
  98. package/lib/locator.js +10 -6
  99. package/lib/mochaFactory.js +15 -18
  100. package/lib/output.js +10 -6
  101. package/lib/parser.js +12 -15
  102. package/lib/pause.js +33 -40
  103. package/lib/plugin/allure.js +15 -15
  104. package/lib/plugin/autoDelay.js +37 -29
  105. package/lib/plugin/autoLogin.js +65 -70
  106. package/lib/plugin/commentStep.js +18 -18
  107. package/lib/plugin/coverage.js +67 -115
  108. package/lib/plugin/customLocator.js +20 -21
  109. package/lib/plugin/debugErrors.js +24 -24
  110. package/lib/plugin/eachElement.js +38 -38
  111. package/lib/plugin/fakerTransform.js +6 -6
  112. package/lib/plugin/heal.js +108 -67
  113. package/lib/plugin/pauseOnFail.js +11 -11
  114. package/lib/plugin/retryFailedStep.js +39 -32
  115. package/lib/plugin/retryTo.js +40 -46
  116. package/lib/plugin/screenshotOnFail.js +87 -109
  117. package/lib/plugin/selenoid.js +118 -131
  118. package/lib/plugin/standardActingHelpers.js +8 -2
  119. package/lib/plugin/stepByStepReport.js +91 -110
  120. package/lib/plugin/stepTimeout.js +23 -24
  121. package/lib/plugin/subtitles.js +35 -34
  122. package/lib/plugin/tryTo.js +30 -40
  123. package/lib/plugin/wdio.js +75 -78
  124. package/lib/recorder.js +17 -14
  125. package/lib/rerun.js +10 -11
  126. package/lib/scenario.js +23 -25
  127. package/lib/secret.js +2 -4
  128. package/lib/session.js +10 -10
  129. package/lib/step.js +9 -12
  130. package/lib/store.js +3 -2
  131. package/lib/transform.js +1 -1
  132. package/lib/translation.js +8 -7
  133. package/lib/ui.js +14 -12
  134. package/lib/utils.js +72 -70
  135. package/lib/within.js +10 -10
  136. package/lib/workerStorage.js +25 -27
  137. package/lib/workers.js +32 -29
  138. package/package.json +53 -51
  139. package/translations/de-DE.js +1 -1
  140. package/translations/fr-FR.js +1 -1
  141. package/translations/index.js +13 -9
  142. package/translations/it-IT.js +1 -1
  143. package/translations/ja-JP.js +1 -1
  144. package/translations/pl-PL.js +1 -1
  145. package/translations/pt-BR.js +1 -1
  146. package/translations/ru-RU.js +1 -1
  147. package/translations/zh-CN.js +1 -1
  148. package/translations/zh-TW.js +1 -1
  149. package/typings/index.d.ts +65 -415
  150. package/typings/promiseBasedTypes.d.ts +32 -0
  151. package/typings/types.d.ts +32 -0
@@ -7,427 +7,125 @@
7
7
  /// <reference types="playwright" />
8
8
 
9
9
  declare namespace CodeceptJS {
10
- type WithTranslation<T> = T &
11
- // @ts-ignore
12
- import("./utils").Translate<T, Translation.Actions>;
10
+ // Utility Types
11
+ type WithTranslation<T> = T & import("./utils").Translate<T, Translation.Actions>;
13
12
 
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
21
22
  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 */
25
24
  Feature?: number;
26
- /** Number of times to repeat scenarios */
27
25
  Scenario?: number;
28
- /** Number of times to repeat Before hook */
29
26
  Before?: number;
30
- /** Number of times to repeat After hook */
31
27
  After?: number;
32
- /** Number of times to repeat BeforeSuite hook */
33
28
  BeforeSuite?: number;
34
- /** Number of times to repeat AfterSuite hook */
35
29
  AfterSuite?: number;
36
30
  };
37
31
 
32
+ // Timeout Configuration
38
33
  type TimeoutConfig = {
39
- /** Filter tests by string or regexp pattern */
40
34
  grep: string | RegExp;
41
- /** Set timeout for a scenarios of a Feature */
42
35
  Feature: number;
43
- /** Set timeout for scenarios */
44
36
  Scenario: number;
45
37
  };
46
38
 
39
+ // AI Configuration
47
40
  type AiPrompt = {
48
41
  role: string;
49
42
  content: string;
50
- }
43
+ };
51
44
 
52
45
  type AiConfig = {
53
- /** request function to send prompts to AI provider */
54
- request: (messages: any) => Promise<string>,
55
-
56
- /** custom prompts */
46
+ request: (messages: any) => Promise<string>;
57
47
  prompts?: {
58
- /** Returns prompt to write CodeceptJS steps inside pause mode */
59
48
  writeStep?: (html: string, input: string) => Array<AiPrompt>;
60
- /** Returns prompt to heal step when test fails on CI if healing is on */
61
49
  healStep?: (html: string, object) => Array<AiPrompt>;
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 */
50
+ generatePageObject?: (
51
+ html: string,
52
+ extraPrompt?: string,
53
+ rootLocator?: string
54
+ ) => Array<AiPrompt>;
55
+ };
56
+ maxTokens?: number;
71
57
  html?: {
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
- }
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
+ };
84
67
 
68
+ // Main Configuration
85
69
  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
- */
100
70
  tests: string;
101
- /**
102
- * Where to store failure screenshots, artifacts, etc
103
- *
104
- * ```js
105
- * output: './output'
106
- * ```
107
- */
108
71
  output: string;
109
- /**
110
- * empty output folder for next run
111
- *
112
- * ```js
113
- * emptyOutputFolder: true
114
- * ```
115
- */
116
72
  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
- */
127
73
  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
- */
140
74
  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
- */
153
75
  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
- */
166
76
  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
- */
180
77
  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
- */
191
78
  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
- */
204
79
  JSONResponse?: any;
205
-
206
- /** Enable AI features for development purposes */
207
80
  AI?: any;
208
-
209
81
  [key: string]: any;
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
- */
82
+ };
228
83
  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
- */
243
84
  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
- */
264
85
  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
- */
299
86
  retry?: number | Array<RetryConfig> | RetryConfig;
300
-
301
-
302
- /** Disable registering global functions (Before, Scenario, etc). Not recommended */
303
87
  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
- */
321
88
  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
- */
335
89
  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
- */
349
90
  teardown?: (() => Promise<void>) | boolean | string;
350
- /**
351
- * [Execute code before launching tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall)
352
- *
353
- */
354
91
  bootstrapAll?: (() => Promise<void>) | boolean | string;
355
- /**
356
- * [Execute JS code after finishing tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall)
357
- */
358
92
  teardownAll?: (() => Promise<void>) | boolean | string;
359
-
360
- /** Enable [localized test commands](https://codecept.io/translation/) */
361
93
  translation?: string;
362
-
363
- /** Additional vocabularies for [localication](https://codecept.io/translation/) */
364
94
  vocabularies?: Array<string>;
365
-
366
- /**
367
- * [Require additional JS modules](https://codecept.io/configuration/#require)
368
- *
369
- * Example:
370
- * ```
371
- * require: ["should"]
372
- * ```
373
- */
374
95
  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
- */
387
96
  gherkin?: {
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>
97
+ features: string | Array<string>;
98
+ steps: string | Array<string>;
392
99
  };
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
- */
100
+ ai?: AiConfig;
404
101
  fullPromiseBased?: boolean;
405
-
406
102
  [key: string]: any;
407
103
  };
408
104
 
105
+ // Mocking
409
106
  type MockRequest = {
410
- method: 'GET'|'PUT'|'POST'|'PATCH'|'DELETE'|string;
107
+ method: 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | string;
411
108
  path: string;
412
109
  queryParams?: object;
413
- }
110
+ };
414
111
 
415
112
  type MockResponse = {
416
113
  status: number;
417
114
  body?: object;
418
- }
115
+ };
419
116
 
420
117
  type MockInteraction = {
421
118
  request: MockRequest;
422
119
  response: MockResponse;
423
- }
120
+ };
424
121
 
122
+ // Page Scroll
425
123
  interface PageScrollPosition {
426
124
  x: number;
427
125
  y: number;
428
126
  }
429
127
 
430
- // Could get extended by user generated typings
128
+ // Actors and Support
431
129
  interface Methods extends ActorStatic {}
432
130
  interface I {}
433
131
  interface IHook {}
@@ -435,24 +133,11 @@ declare namespace CodeceptJS {
435
133
  interface IFeature {
436
134
  (title: string): FeatureConfig;
437
135
  }
438
- interface CallbackOrder extends Array<any> {}
439
136
  interface SupportObject {
440
137
  I: CodeceptJS.I;
441
138
  }
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>;
455
139
 
140
+ // Locator Types
456
141
  type ILocator =
457
142
  | { id: string }
458
143
  | { xpath: string }
@@ -461,41 +146,38 @@ declare namespace CodeceptJS {
461
146
  | { frame: string }
462
147
  | { android: string }
463
148
  | { ios: string }
464
- | { android: string; ios: string }
465
149
  | { react: string }
466
150
  | { vue: string }
467
151
  | { shadow: string[] }
468
152
  | { custom: string }
469
153
  | { pw: string };
470
- interface CustomLocators {}
471
- interface OtherLocators { props?: object }
472
- type LocatorOrString =
473
- | string
474
- | ILocator
475
- | Locator
476
- | OtherLocators
477
- | CustomLocators[keyof CustomLocators];
154
+
155
+ type LocatorOrString = string | ILocator | OtherLocators | CustomLocators[keyof CustomLocators];
478
156
 
479
157
  type StringOrSecret = string | CodeceptJS.Secret;
480
158
 
159
+ // Hook and Scenario Callbacks
481
160
  interface HookCallback {
482
161
  (args: SupportObject): void | Promise<void>;
483
162
  }
163
+
484
164
  interface Scenario extends IScenario {
485
165
  only: IScenario;
486
166
  skip: IScenario;
487
167
  todo: IScenario;
488
168
  }
169
+
489
170
  interface Feature extends IFeature {
490
171
  skip: IFeature;
491
172
  }
173
+
492
174
  interface IData {
493
175
  Scenario: IScenario;
494
176
  only: { Scenario: IScenario };
495
177
  }
496
178
 
179
+ // Scenario Interface
497
180
  interface IScenario {
498
- // Scenario.todo can be called only with a title.
499
181
  (title: string, callback?: HookCallback): ScenarioConfig;
500
182
  (
501
183
  title: string,
@@ -503,44 +185,39 @@ declare namespace CodeceptJS {
503
185
  callback: HookCallback
504
186
  ): ScenarioConfig;
505
187
  }
188
+
506
189
  interface IHook {
507
190
  (callback: HookCallback): void;
508
191
  }
509
192
 
193
+ // Global Utilities
510
194
  interface Globals {
511
195
  codeceptjs: typeof codeceptjs;
512
196
  }
513
197
 
198
+ // BDD Parameter Types
514
199
  interface IParameterTypeDefinition<T> {
515
- name: string
516
- regexp: readonly RegExp[] | readonly string[] | RegExp | string
517
- transformer: (...match: string[]) => T
518
- useForSnippets?: boolean
519
- preferForRegexpMatch?: boolean
200
+ name: string;
201
+ regexp: readonly RegExp[] | readonly string[] | RegExp | string;
202
+ transformer: (...match: string[]) => T;
203
+ useForSnippets?: boolean;
204
+ preferForRegexpMatch?: boolean;
520
205
  }
521
206
  }
522
207
 
523
208
  // Globals
524
209
  declare const codecept_dir: string;
525
210
  declare const output_dir: string;
526
- declare function tryTo(...fn): Promise<boolean>;
527
- declare function retryTo(...fn): Promise<null>;
211
+ declare function tryTo<T>(...fn: unknown[]): Promise<T>;
212
+ declare function retryTo<T>(...fn: unknown[]): Promise<T>;
528
213
 
529
214
  declare const actor: CodeceptJS.actor;
530
- declare const codecept_actor: CodeceptJS.actor;
531
215
  declare const Helper: typeof CodeceptJS.Helper;
532
- declare const codecept_helper: typeof CodeceptJS.Helper;
533
216
  declare const pause: typeof CodeceptJS.pause;
534
217
  declare const within: typeof CodeceptJS.within;
535
218
  declare const session: typeof CodeceptJS.session;
536
219
  declare const DataTable: typeof CodeceptJS.DataTable;
537
- declare const DataTableArgument: typeof CodeceptJS.DataTableArgument;
538
- declare const codeceptjs: typeof CodeceptJS.index;
539
220
  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];
544
221
  declare const secret: typeof CodeceptJS.Secret.secret;
545
222
 
546
223
  // BDD
@@ -548,58 +225,37 @@ declare const Given: typeof CodeceptJS.addStep;
548
225
  declare const When: typeof CodeceptJS.addStep;
549
226
  declare const Then: typeof CodeceptJS.addStep;
550
227
 
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
-
559
228
  // Hooks
560
229
  declare const BeforeSuite: CodeceptJS.IHook;
561
230
  declare const AfterSuite: CodeceptJS.IHook;
562
- declare const Background: CodeceptJS.IHook;
563
231
  declare const Before: CodeceptJS.IHook;
564
232
  declare const After: CodeceptJS.IHook;
565
233
 
566
- // Plugins
567
- declare const __: any
568
-
569
- interface Window {
570
- resq: any;
571
- }
572
-
234
+ // Process Interface
573
235
  declare namespace NodeJS {
574
236
  interface Process {
575
- profile: string;
237
+ profile?: string;
238
+ env?: {
239
+ [key: string]: string | undefined;
240
+ };
576
241
  }
577
242
 
578
243
  interface Global extends CodeceptJS.Globals {
579
244
  codecept_dir: typeof codecept_dir;
580
245
  output_dir: typeof output_dir;
581
-
582
246
  actor: typeof actor;
583
- codecept_actor: typeof codecept_actor;
584
247
  Helper: typeof Helper;
585
- codecept_helper: typeof codecept_helper;
586
248
  pause: typeof pause;
587
249
  within: typeof within;
588
250
  session: typeof session;
589
251
  DataTable: typeof DataTable;
590
- DataTableArgument: typeof DataTableArgument;
591
252
  locate: typeof locate;
592
- inject: typeof inject;
593
253
  secret: typeof secret;
594
- // plugins
595
254
  tryTo: typeof tryTo;
596
255
  retryTo: typeof retryTo;
597
-
598
- // BDD
599
256
  Given: typeof Given;
600
257
  When: typeof When;
601
258
  Then: typeof Then;
602
- DefineParameterType: typeof defineParameterType
603
259
  }
604
260
  }
605
261
 
@@ -607,26 +263,20 @@ declare namespace Mocha {
607
263
  interface MochaGlobals {
608
264
  Feature: typeof Feature;
609
265
  Scenario: typeof Scenario;
610
- xFeature: typeof xFeature;
611
- xScenario: typeof xScenario;
612
- Data: typeof Data;
613
- xData: typeof xData;
614
266
  BeforeSuite: typeof BeforeSuite;
615
267
  AfterSuite: typeof AfterSuite;
616
- Background: typeof Background;
617
268
  Before: typeof Before;
618
269
  After: typeof After;
619
270
  }
620
271
 
621
272
  interface Suite extends SuiteRunnable {
622
- tags: any[];
623
- comment: string;
624
- feature: any;
273
+ tags?: any[];
274
+ feature?: any;
625
275
  }
626
276
 
627
277
  interface Test extends Runnable {
628
- artifacts: [],
629
- tags: any[];
278
+ artifacts?: [];
279
+ tags?: any[];
630
280
  }
631
281
  }
632
282