codeceptjs 2.4.3 → 2.6.2

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 (76) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/README.md +32 -7
  3. package/bin/codecept.js +3 -0
  4. package/docs/basics.md +11 -5
  5. package/docs/bdd.md +4 -4
  6. package/docs/build/MockRequest.js +3 -0
  7. package/docs/build/Nightmare.js +10 -2
  8. package/docs/build/Playwright.js +3187 -0
  9. package/docs/build/Protractor.js +16 -2
  10. package/docs/build/Puppeteer.js +126 -19
  11. package/docs/build/REST.js +3 -1
  12. package/docs/build/TestCafe.js +11 -3
  13. package/docs/build/WebDriver.js +361 -28
  14. package/docs/changelog.md +116 -0
  15. package/docs/configuration.md +2 -2
  16. package/docs/custom-helpers.md +55 -10
  17. package/docs/helpers/Appium.md +81 -1
  18. package/docs/helpers/MockRequest.md +281 -38
  19. package/docs/helpers/Nightmare.md +10 -2
  20. package/docs/helpers/Playwright.md +1770 -0
  21. package/docs/helpers/Protractor.md +15 -3
  22. package/docs/helpers/Puppeteer-firefox.md +32 -1
  23. package/docs/helpers/Puppeteer.md +126 -76
  24. package/docs/helpers/TestCafe.md +10 -2
  25. package/docs/helpers/WebDriver.md +208 -118
  26. package/docs/locators.md +2 -0
  27. package/docs/playwright.md +306 -0
  28. package/docs/plugins.md +103 -0
  29. package/docs/reports.md +12 -0
  30. package/docs/shadow.md +68 -0
  31. package/docs/visual.md +0 -73
  32. package/docs/webapi/forceClick.mustache +27 -0
  33. package/docs/webapi/seeInPopup.mustache +7 -0
  34. package/docs/webapi/setCookie.mustache +10 -2
  35. package/docs/webapi/type.mustache +12 -0
  36. package/docs/webdriver.md +7 -3
  37. package/lib/codecept.js +1 -1
  38. package/lib/command/definitions.js +2 -2
  39. package/lib/command/generate.js +4 -4
  40. package/lib/command/gherkin/snippets.js +4 -4
  41. package/lib/command/init.js +1 -1
  42. package/lib/command/interactive.js +3 -0
  43. package/lib/command/run-multiple.js +2 -2
  44. package/lib/command/run-rerun.js +2 -0
  45. package/lib/command/run-workers.js +22 -8
  46. package/lib/command/run.js +2 -0
  47. package/lib/command/workers/runTests.js +1 -0
  48. package/lib/container.js +1 -1
  49. package/lib/event.js +2 -0
  50. package/lib/helper/MockRequest.js +3 -0
  51. package/lib/helper/Playwright.js +2422 -0
  52. package/lib/helper/Protractor.js +1 -2
  53. package/lib/helper/Puppeteer.js +84 -19
  54. package/lib/helper/REST.js +3 -1
  55. package/lib/helper/TestCafe.js +1 -1
  56. package/lib/helper/WebDriver.js +313 -26
  57. package/lib/helper/extras/PlaywrightPropEngine.js +53 -0
  58. package/lib/helper/scripts/isElementClickable.js +54 -14
  59. package/lib/interfaces/gherkin.js +1 -1
  60. package/lib/listener/helpers.js +3 -0
  61. package/lib/locator.js +5 -0
  62. package/lib/mochaFactory.js +12 -10
  63. package/lib/plugin/allure.js +8 -1
  64. package/lib/plugin/autoDelay.js +1 -8
  65. package/lib/plugin/commentStep.js +133 -0
  66. package/lib/plugin/screenshotOnFail.js +3 -10
  67. package/lib/plugin/selenoid.js +2 -2
  68. package/lib/plugin/standardActingHelpers.js +13 -0
  69. package/lib/plugin/stepByStepReport.js +1 -8
  70. package/lib/plugin/wdio.js +10 -1
  71. package/lib/reporter/cli.js +30 -1
  72. package/lib/session.js +7 -4
  73. package/package.json +13 -10
  74. package/typings/Mocha.d.ts +567 -16
  75. package/typings/index.d.ts +9 -5
  76. package/typings/types.d.ts +1634 -74
@@ -1,21 +1,572 @@
1
- /// <reference types="Mocha" />
1
+ declare module Mocha {
2
+ class SuiteRunnable {
3
+ private _beforeEach;
4
+ private _beforeAll;
5
+ private _afterEach;
6
+ private _afterAll;
7
+ private _timeout;
8
+ private _enableTimeouts;
9
+ private _slow;
10
+ private _bail;
11
+ private _retries;
12
+ private _onlyTests;
13
+ private _onlySuites;
14
+
15
+ constructor(title: string, parentContext?: Context);
16
+
17
+ ctx: Context;
18
+ suites: Suite[];
19
+ tests: Test[];
20
+ pending: boolean;
21
+ file?: string;
22
+ root: boolean;
23
+ delayed: boolean;
24
+ parent: Suite | undefined;
25
+ title: string;
26
+
27
+ /**
28
+ * Create a new `Suite` with the given `title` and parent `Suite`. When a suite
29
+ * with the same title is already present, that suite is returned to provide
30
+ * nicer reporter and more flexible meta-testing.
31
+ *
32
+ * @see https://mochajs.org/api/mocha#.exports.create
33
+ */
34
+ static create(parent: Suite, title: string): Suite;
35
+
36
+ /**
37
+ * Return a clone of this `Suite`.
38
+ *
39
+ * @see https://mochajs.org/api/Mocha.Suite.html#clone
40
+ */
41
+ clone(): Suite;
42
+
43
+ /**
44
+ * Get timeout `ms`.
45
+ *
46
+ * @see https://mochajs.org/api/Mocha.Suite.html#timeout
47
+ */
48
+ timeout(): number;
49
+
50
+ /**
51
+ * Set timeout `ms` or short-hand such as "2s".
52
+ *
53
+ * @see https://mochajs.org/api/Mocha.Suite.html#timeout
54
+ */
55
+ timeout(ms: string | number): this;
56
+
57
+ /**
58
+ * Get number of times to retry a failed test.
59
+ *
60
+ * @see https://mochajs.org/api/Mocha.Suite.html#retries
61
+ */
62
+ retries(): number;
63
+
64
+ /**
65
+ * Set number of times to retry a failed test.
66
+ *
67
+ * @see https://mochajs.org/api/Mocha.Suite.html#retries
68
+ */
69
+ retries(n: string | number): this;
70
+
71
+ /**
72
+ * Get whether timeouts are enabled.
73
+ *
74
+ * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
75
+ */
76
+ enableTimeouts(): boolean;
77
+
78
+ /**
79
+ * Set whether timeouts are `enabled`.
80
+ *
81
+ * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
82
+ */
83
+ enableTimeouts(enabled: boolean): this;
84
+
85
+ /**
86
+ * Get slow `ms`.
87
+ *
88
+ * @see https://mochajs.org/api/Mocha.Suite.html#slow
89
+ */
90
+ slow(): number;
91
+
92
+ /**
93
+ * Set slow `ms` or short-hand such as "2s".
94
+ *
95
+ * @see https://mochajs.org/api/Mocha.Suite.html#slow
96
+ */
97
+ slow(ms: string | number): this;
98
+
99
+ /**
100
+ * Get whether to bail after first error.
101
+ *
102
+ * @see https://mochajs.org/api/Mocha.Suite.html#bail
103
+ */
104
+ bail(): boolean;
105
+
106
+ /**
107
+ * Set whether to bail after first error.
108
+ *
109
+ * @see https://mochajs.org/api/Mocha.Suite.html#bail
110
+ */
111
+ bail(bail: boolean): this;
112
+
113
+ /**
114
+ * Check if this suite or its parent suite is marked as pending.
115
+ *
116
+ * @see https://mochajs.org/api/Mocha.Suite.html#isPending
117
+ */
118
+ isPending(): boolean;
119
+
120
+ /**
121
+ * Run `fn(test[, done])` before running tests.
122
+ *
123
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
124
+ */
125
+ beforeAll(fn?: Func): this;
126
+
127
+ /**
128
+ * Run `fn(test[, done])` before running tests.
129
+ *
130
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
131
+ */
132
+ beforeAll(fn?: AsyncFunc): this;
133
+
134
+ /**
135
+ * Run `fn(test[, done])` before running tests.
136
+ *
137
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
138
+ */
139
+ beforeAll(title: string, fn?: Func): this;
140
+
141
+ /**
142
+ * Run `fn(test[, done])` before running tests.
143
+ *
144
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
145
+ */
146
+ beforeAll(title: string, fn?: AsyncFunc): this;
147
+
148
+ /**
149
+ * Run `fn(test[, done])` after running tests.
150
+ *
151
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
152
+ */
153
+ afterAll(fn?: Func): this;
154
+
155
+ /**
156
+ * Run `fn(test[, done])` after running tests.
157
+ *
158
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
159
+ */
160
+ afterAll(fn?: AsyncFunc): this;
161
+
162
+ /**
163
+ * Run `fn(test[, done])` after running tests.
164
+ *
165
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
166
+ */
167
+ afterAll(title: string, fn?: Func): this;
168
+
169
+ /**
170
+ * Run `fn(test[, done])` after running tests.
171
+ *
172
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
173
+ */
174
+ afterAll(title: string, fn?: AsyncFunc): this;
175
+
176
+ /**
177
+ * Run `fn(test[, done])` before each test case.
178
+ *
179
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
180
+ */
181
+ beforeEach(fn?: Func): this;
182
+
183
+ /**
184
+ * Run `fn(test[, done])` before each test case.
185
+ *
186
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
187
+ */
188
+ beforeEach(fn?: AsyncFunc): this;
189
+
190
+ /**
191
+ * Run `fn(test[, done])` before each test case.
192
+ *
193
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
194
+ */
195
+ beforeEach(title: string, fn?: Func): this;
196
+
197
+ /**
198
+ * Run `fn(test[, done])` before each test case.
199
+ *
200
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
201
+ */
202
+ beforeEach(title: string, fn?: AsyncFunc): this;
203
+
204
+ /**
205
+ * Run `fn(test[, done])` after each test case.
206
+ *
207
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
208
+ */
209
+ afterEach(fn?: Func): this;
210
+
211
+ /**
212
+ * Run `fn(test[, done])` after each test case.
213
+ *
214
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
215
+ */
216
+ afterEach(fn?: AsyncFunc): this;
217
+
218
+ /**
219
+ * Run `fn(test[, done])` after each test case.
220
+ *
221
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
222
+ */
223
+ afterEach(title: string, fn?: Func): this;
224
+
225
+ /**
226
+ * Run `fn(test[, done])` after each test case.
227
+ *
228
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
229
+ */
230
+ afterEach(title: string, fn?: AsyncFunc): this;
231
+
232
+ /**
233
+ * Add a test `suite`.
234
+ *
235
+ * @see https://mochajs.org/api/Mocha.Suite.html#addSuite
236
+ */
237
+ addSuite(suite: Suite): this;
238
+
239
+ /**
240
+ * Add a `test` to this suite.
241
+ *
242
+ * @see https://mochajs.org/api/Mocha.Suite.html#addTest
243
+ */
244
+ addTest(test: Test): this;
245
+
246
+ /**
247
+ * Return the full title generated by recursively concatenating the parent's
248
+ * full title.
249
+ *
250
+ * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle
251
+ */
252
+ fullTitle(): string;
253
+
254
+ /**
255
+ * Return the title path generated by recursively concatenating the parent's
256
+ * title path.
257
+ *
258
+ * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath
259
+ */
260
+ titlePath(): string[];
261
+
262
+ /**
263
+ * Return the total number of tests.
264
+ *
265
+ * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total
266
+ */
267
+ total(): number;
268
+
269
+ /**
270
+ * Iterates through each suite recursively to find all tests. Applies a
271
+ * function in the format `fn(test)`.
272
+ *
273
+ * @see https://mochajs.org/api/Mocha.Suite.html#eachTest
274
+ */
275
+ eachTest(fn: (test: Test) => void): this;
276
+
277
+ /**
278
+ * This will run the root suite if we happen to be running in delayed mode.
279
+ *
280
+ * @see https://mochajs.org/api/Mocha.Suite.html#run
281
+ */
282
+ run(): void;
283
+
284
+ /**
285
+ * Generic hook-creator.
286
+ */
287
+ protected _createHook(title: string, fn?: Func | AsyncFunc): Hook;
288
+ }
2
289
 
3
- declare module "mocha/lib/reporters/base" {
4
- export = Mocha.reporters.Base;
5
- }
290
+ /**
291
+ * Initialize a new `Hook` with the given `title` and callback `fn`
292
+ *
293
+ * @see https://mochajs.org/api/Hook.html
294
+ */
295
+ class Hook extends Runnable {
296
+ private _error;
6
297
 
7
- declare module "mocha/lib/suite" {
8
- export = Mocha.Suite;
9
- }
298
+ type: "hook";
299
+ originalTitle?: string; // added by Runner
10
300
 
11
- declare module "mocha/lib/context" {
12
- export = Mocha.Context;
13
- }
301
+ /**
302
+ * Get the test `err`.
303
+ *
304
+ * @see https://mochajs.org/api/Hook.html#error
305
+ */
306
+ error(): any;
14
307
 
15
- declare module "mocha/lib/test" {
16
- export = Mocha.Test;
17
- }
308
+ /**
309
+ * Set the test `err`.
310
+ *
311
+ * @see https://mochajs.org/api/Hook.html#error
312
+ */
313
+ error(err: any): void;
314
+ }
18
315
 
19
- declare module "mocha/lib/mocha" {
20
- export = Mocha;
21
- }
316
+ /**
317
+ * Initialize a new `Runnable` with the given `title` and callback `fn`.
318
+ *
319
+ * @see https://mochajs.org/api/Runnable.html
320
+ */
321
+ class Runnable {
322
+ private _slow;
323
+ private _enableTimeouts;
324
+ private _retries;
325
+ private _currentRetry;
326
+ private _timeout;
327
+ private _timeoutError;
328
+
329
+ constructor(title: string, fn?: Func | AsyncFunc);
330
+
331
+ title: string;
332
+ fn: Func | AsyncFunc | undefined;
333
+ body: string;
334
+ async: boolean;
335
+ sync: boolean;
336
+ timedOut: boolean;
337
+ pending: boolean;
338
+ duration?: number;
339
+ parent?: Suite;
340
+ state?: "failed" | "passed";
341
+ timer?: any;
342
+ ctx?: Context;
343
+ callback?: Done;
344
+ allowUncaught?: boolean;
345
+ file?: string;
346
+
347
+ /**
348
+ * Get test timeout.
349
+ *
350
+ * @see https://mochajs.org/api/Runnable.html#timeout
351
+ */
352
+ timeout(): number;
353
+
354
+ /**
355
+ * Set test timeout.
356
+ *
357
+ * @see https://mochajs.org/api/Runnable.html#timeout
358
+ */
359
+ timeout(ms: string | number): this;
360
+
361
+ /**
362
+ * Get test slowness threshold.
363
+ *
364
+ * @see https://mochajs.org/api/Runnable.html#slow
365
+ */
366
+ slow(): number;
367
+
368
+ /**
369
+ * Set test slowness threshold.
370
+ *
371
+ * @see https://mochajs.org/api/Runnable.html#slow
372
+ */
373
+ slow(ms: string | number): this;
374
+
375
+ /**
376
+ * Get whether timeouts are enabled.
377
+ *
378
+ * @see https://mochajs.org/api/Runnable.html#enableTimeouts
379
+ */
380
+ enableTimeouts(): boolean;
381
+
382
+ /**
383
+ * Set whether timeouts are enabled.
384
+ *
385
+ * @see https://mochajs.org/api/Runnable.html#enableTimeouts
386
+ */
387
+ enableTimeouts(enabled: boolean): this;
388
+
389
+ /**
390
+ * Halt and mark as pending.
391
+ */
392
+ skip(): never;
393
+
394
+ /**
395
+ * Check if this runnable or its parent suite is marked as pending.
396
+ *
397
+ * @see https://mochajs.org/api/Runnable.html#isPending
398
+ */
399
+ isPending(): boolean;
400
+
401
+ /**
402
+ * Return `true` if this Runnable has failed.
403
+ */
404
+ isFailed(): boolean;
405
+
406
+ /**
407
+ * Return `true` if this Runnable has passed.
408
+ */
409
+ isPassed(): boolean;
410
+
411
+ /**
412
+ * Set or get number of retries.
413
+ *
414
+ * @see https://mochajs.org/api/Runnable.html#retries
415
+ */
416
+ retries(): number;
417
+
418
+ /**
419
+ * Set or get number of retries.
420
+ *
421
+ * @see https://mochajs.org/api/Runnable.html#retries
422
+ */
423
+ retries(n: number): void;
424
+
425
+ /**
426
+ * Set or get current retry
427
+ *
428
+ * @see https://mochajs.org/api/Runnable.html#currentRetry
429
+ */
430
+ protected currentRetry(): number;
431
+
432
+ /**
433
+ * Set or get current retry
434
+ *
435
+ * @see https://mochajs.org/api/Runnable.html#currentRetry
436
+ */
437
+ protected currentRetry(n: number): void;
438
+
439
+ /**
440
+ * Return the full title generated by recursively concatenating the parent's full title.
441
+ */
442
+ fullTitle(): string;
443
+
444
+ /**
445
+ * Return the title path generated by concatenating the parent's title path with the title.
446
+ */
447
+ titlePath(): string[];
448
+
449
+ /**
450
+ * Clear the timeout.
451
+ *
452
+ * @see https://mochajs.org/api/Runnable.html#clearTimeout
453
+ */
454
+ clearTimeout(): void;
455
+
456
+ /**
457
+ * Inspect the runnable void of private properties.
458
+ *
459
+ * @see https://mochajs.org/api/Runnable.html#inspect
460
+ */
461
+ inspect(): string;
462
+
463
+ /**
464
+ * Reset the timeout.
465
+ *
466
+ * @see https://mochajs.org/api/Runnable.html#resetTimeout
467
+ */
468
+ resetTimeout(): void;
469
+
470
+ /**
471
+ * Get a list of whitelisted globals for this test run.
472
+ *
473
+ * @see https://mochajs.org/api/Runnable.html#globals
474
+ */
475
+ globals(): string[];
476
+
477
+ /**
478
+ * Set a list of whitelisted globals for this test run.
479
+ *
480
+ * @see https://mochajs.org/api/Runnable.html#globals
481
+ */
482
+ globals(globals: ReadonlyArray<string>): void;
483
+
484
+ /**
485
+ * Run the test and invoke `fn(err)`.
486
+ *
487
+ * @see https://mochajs.org/api/Runnable.html#run
488
+ */
489
+ run(fn: Done): void;
490
+ }
491
+
492
+ type Done = (err?: any) => void;
493
+
494
+ /**
495
+ * Callback function used for tests and hooks.
496
+ */
497
+ type Func = (this: Context, done: Done) => void;
498
+
499
+ /**
500
+ * Async callback function used for tests and hooks.
501
+ */
502
+ type AsyncFunc = (this: Context) => PromiseLike<any>;
503
+
504
+ /**
505
+ * Test context
506
+ *
507
+ * @see https://mochajs.org/api/module-Context.html#~Context
508
+ */
509
+ class Context {
510
+ private _runnable;
511
+
512
+ test?: Runnable;
513
+ currentTest?: Test;
514
+
515
+ /**
516
+ * Get the context `Runnable`.
517
+ */
518
+ runnable(): Runnable;
519
+
520
+ /**
521
+ * Set the context `Runnable`.
522
+ */
523
+ runnable(runnable: Runnable): this;
524
+
525
+ /**
526
+ * Get test timeout.
527
+ */
528
+ timeout(): number;
529
+
530
+ /**
531
+ * Set test timeout.
532
+ */
533
+ timeout(ms: string | number): this;
534
+
535
+ /**
536
+ * Get whether timeouts are enabled.
537
+ */
538
+ enableTimeouts(): boolean;
539
+
540
+ /**
541
+ * Set whether timeouts are enabled.
542
+ */
543
+ enableTimeouts(enabled: boolean): this;
544
+
545
+ /**
546
+ * Get test slowness threshold.
547
+ */
548
+ slow(): number;
549
+
550
+ /**
551
+ * Set test slowness threshold.
552
+ */
553
+ slow(ms: string | number): this;
554
+
555
+ /**
556
+ * Mark a test as skipped.
557
+ */
558
+ skip(): never;
559
+
560
+ /**
561
+ * Get the number of allowed retries on failed tests.
562
+ */
563
+ retries(): number;
564
+
565
+ /**
566
+ * Set the number of allowed retries on failed tests.
567
+ */
568
+ retries(n: number): this;
569
+
570
+ [key: string]: any;
571
+ }
572
+ }
@@ -2,7 +2,7 @@
2
2
  // Project: https://github.com/codeception/codeceptjs/
3
3
  /// <reference path="./types.d.ts" />
4
4
  /// <reference types="webdriverio" />
5
- /// <reference types="Mocha" />
5
+ /// <reference path="./Mocha.d.ts" />
6
6
 
7
7
  declare namespace CodeceptJS {
8
8
  type WithTranslation<T> = T &
@@ -45,10 +45,14 @@ declare namespace CodeceptJS {
45
45
  type LocatorOrString = string | ILocator | Locator;
46
46
 
47
47
  interface HookCallback<U extends any[]> { (...args: U): void; }
48
- interface Scenario extends IScenario { only: IScenario, skip: IScenario }
48
+ interface Scenario extends IScenario { only: IScenario, skip: IScenario, todo: IScenario}
49
49
  interface IData { Scenario: IScenario, only: { Scenario: IScenario } }
50
50
 
51
51
  interface IScenario {
52
+ // Scenario.todo can be called only with a title.
53
+ <T extends any[] = CallbackOrder>(
54
+ title: string
55
+ ): ScenarioConfig;
52
56
  <T extends any[] = CallbackOrder>(
53
57
  title: string,
54
58
  callback: HookCallback<T>
@@ -153,14 +157,14 @@ declare namespace Mocha {
153
157
  After: typeof After;
154
158
  }
155
159
 
156
- interface Suite {
160
+ interface Suite extends SuiteRunnable{
157
161
  tags: any[]
158
162
  comment: string
159
163
  feature: any
160
164
  }
161
165
 
162
- interface Test {
163
- tags: any[]
166
+ interface Test extends Runnable{
167
+ tags: any[];
164
168
  }
165
169
  }
166
170