codeceptjs 4.0.0-beta.3 → 4.0.0-beta.5

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