codeceptjs 3.1.3 → 3.2.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 (75) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/README.md +2 -3
  3. package/bin/codecept.js +1 -0
  4. package/docs/advanced.md +99 -61
  5. package/docs/basics.md +27 -2
  6. package/docs/bdd.md +2 -2
  7. package/docs/build/Appium.js +62 -0
  8. package/docs/build/FileSystem.js +12 -1
  9. package/docs/build/Playwright.js +37 -33
  10. package/docs/build/Protractor.js +9 -24
  11. package/docs/build/Puppeteer.js +10 -28
  12. package/docs/build/REST.js +1 -0
  13. package/docs/build/WebDriver.js +2 -24
  14. package/docs/changelog.md +75 -1
  15. package/docs/configuration.md +8 -8
  16. package/docs/custom-helpers.md +2 -37
  17. package/docs/data.md +9 -9
  18. package/docs/helpers/Appium.md +240 -198
  19. package/docs/helpers/FileSystem.md +12 -2
  20. package/docs/helpers/Playwright.md +226 -225
  21. package/docs/helpers/Puppeteer.md +1 -17
  22. package/docs/helpers/REST.md +3 -1
  23. package/docs/helpers/WebDriver.md +1 -17
  24. package/docs/installation.md +1 -1
  25. package/docs/mobile-react-native-locators.md +3 -0
  26. package/docs/mobile.md +11 -11
  27. package/docs/nightmare.md +3 -3
  28. package/docs/pageobjects.md +2 -0
  29. package/docs/playwright.md +4 -4
  30. package/docs/plugins.md +138 -9
  31. package/docs/puppeteer.md +5 -5
  32. package/docs/reports.md +3 -3
  33. package/docs/testcafe.md +1 -1
  34. package/docs/translation.md +1 -1
  35. package/docs/visual.md +2 -2
  36. package/docs/vue.md +1 -1
  37. package/docs/webdriver.md +2 -2
  38. package/lib/actor.js +19 -1
  39. package/lib/cli.js +25 -20
  40. package/lib/codecept.js +2 -0
  41. package/lib/command/info.js +1 -1
  42. package/lib/command/workers/runTests.js +25 -7
  43. package/lib/config.js +12 -0
  44. package/lib/container.js +3 -1
  45. package/lib/helper/Appium.js +62 -0
  46. package/lib/helper/FileSystem.js +12 -1
  47. package/lib/helper/Playwright.js +37 -23
  48. package/lib/helper/Protractor.js +2 -14
  49. package/lib/helper/Puppeteer.js +3 -18
  50. package/lib/helper/REST.js +1 -0
  51. package/lib/helper/WebDriver.js +2 -14
  52. package/lib/interfaces/featureConfig.js +3 -0
  53. package/lib/interfaces/scenarioConfig.js +4 -0
  54. package/lib/listener/steps.js +21 -3
  55. package/lib/listener/timeout.js +72 -0
  56. package/lib/locator.js +3 -0
  57. package/lib/plugin/allure.js +6 -1
  58. package/lib/plugin/autoLogin.js +1 -1
  59. package/lib/plugin/retryFailedStep.js +4 -3
  60. package/lib/plugin/retryTo.js +130 -0
  61. package/lib/plugin/screenshotOnFail.js +1 -0
  62. package/lib/plugin/stepByStepReport.js +7 -0
  63. package/lib/plugin/stepTimeout.js +91 -0
  64. package/lib/plugin/tryTo.js +6 -0
  65. package/lib/recorder.js +18 -6
  66. package/lib/step.js +58 -0
  67. package/lib/store.js +2 -0
  68. package/lib/ui.js +2 -2
  69. package/package.json +4 -6
  70. package/typings/index.d.ts +8 -1
  71. package/typings/types.d.ts +149 -164
  72. package/docs/angular.md +0 -325
  73. package/docs/helpers/Protractor.md +0 -1658
  74. package/docs/webapi/waitUntil.mustache +0 -11
  75. package/typings/Protractor.d.ts +0 -16
@@ -582,7 +582,7 @@ class WebDriver extends Helper {
582
582
  this.context = this.root;
583
583
  if (this.options.restart && !this.options.manualStart) return this._startBrowser();
584
584
  if (!this.isRunning && !this.options.manualStart) return this._startBrowser();
585
- this.$$ = this.browser.$$.bind(this.browser);
585
+ if (this.browser) this.$$ = this.browser.$$.bind(this.browser);
586
586
  return this.browser;
587
587
  }
588
588
 
@@ -875,7 +875,7 @@ class WebDriver extends Helper {
875
875
  * I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
876
876
  * ```
877
877
  *
878
- * @param {WebdriverIO.Timeouts} timeouts WebDriver timeouts object.
878
+ * @param {*} timeouts WebDriver timeouts object.
879
879
  */
880
880
  defineTimeout(timeouts) {
881
881
  return this._defineBrowserTimeout(this.browser, timeouts);
@@ -3259,28 +3259,6 @@ class WebDriver extends Helper {
3259
3259
  return this.browser.waitUntil(async () => this.browser.execute(fn, ...args), { timeout: aSec * 1000, timeoutMsg: '' });
3260
3260
  }
3261
3261
 
3262
- /**
3263
- * Waits for a function to return true (waits for 1sec by default).
3264
- *
3265
- * ```js
3266
- * I.waitUntil(() => window.requests == 0);
3267
- * I.waitUntil(() => window.requests == 0, 5);
3268
- * ```
3269
- *
3270
- * @param {function|string} fn function which is executed in browser context.
3271
- * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3272
- * @param {string} [timeoutMsg=''] message to show in case of timeout fail.
3273
- * @param {?number} [interval=null]
3274
- */
3275
- async waitUntil(fn, sec = null, timeoutMsg = null, interval = null) {
3276
- const aSec = sec || this.options.waitForTimeout;
3277
- const _interval = typeof interval === 'number' ? interval * 1000 : null;
3278
- if (isWebDriver5()) {
3279
- return this.browser.waitUntil(fn, aSec * 1000, timeoutMsg, _interval);
3280
- }
3281
- return this.browser.waitUntil(fn, { timeout: aSec * 1000, timeoutMsg, interval: _interval });
3282
- }
3283
-
3284
3262
  /**
3285
3263
  * Switches frame or in case of null locator reverts to parent.
3286
3264
  *
package/docs/changelog.md CHANGED
@@ -7,6 +7,79 @@ layout: Section
7
7
 
8
8
  # Releases
9
9
 
10
+ ## 3.2.3
11
+
12
+ * Documentation improvements by **[maojunxyz](https://github.com/maojunxyz)**
13
+ * Guard mocha cli reporter from registering step logger multiple times [#3180](https://github.com/codeceptjs/CodeceptJS/issues/3180) by **[nikocanvacom](https://github.com/nikocanvacom)**
14
+ * **[Playwright]** Fixed "tracing.stop: tracing.stop: ENAMETOOLONG: name too long" by **[hatufacci](https://github.com/hatufacci)**
15
+ * Fixed [#2889](https://github.com/codeceptjs/CodeceptJS/issues/2889): return always the same error contract from simplifyTest. See [#3168](https://github.com/codeceptjs/CodeceptJS/issues/3168) by **[andremoah](https://github.com/andremoah)**
16
+
17
+ ## 3.2.2
18
+
19
+ * **[Playwright]** Reverted removal of retry on context errors. Fixes [#3130](https://github.com/codeceptjs/CodeceptJS/issues/3130)
20
+ * Timeout improvements by **[nikocanvacom](https://github.com/nikocanvacom)**:
21
+ * Added priorites to timeouts
22
+ * Added `overrideStepLimits` to [stepTimeout plugin](https://codecept.io/plugins/#steptimeout) to override steps timeouts set by `limitTime`.
23
+ * Fixed step timeout not working due to override by NaN by test timeout [#3126](https://github.com/codeceptjs/CodeceptJS/issues/3126)
24
+ * **[Appium]** Fixed logging error when `manualStart` is true. See [#3140](https://github.com/codeceptjs/CodeceptJS/issues/3140) by **[nikocanvacom](https://github.com/nikocanvacom)**
25
+
26
+
27
+ ## 3.2.1
28
+
29
+ > ♻️ This release fixes hanging of tests by reducing timeouts for automatic retries on failures.
30
+
31
+ * [retryFailedStep plugin] **New Defaults**: retries steps up to 3 times with factor of 1.5 (previously 5 with factor 2)
32
+ * **[Playwright]** - disabled retry on failed context actions (not needed anymore)
33
+ * **[Puppeteer]** - reduced retries on context failures to 3 times.
34
+ * **[Playwright]** Handling `crash` event to automatically close crashed pages.
35
+
36
+ ## 3.2.0
37
+
38
+ 🛩️ Features:
39
+
40
+ **[Timeouts](https://codecept.io/advanced/#timeout) implemented**
41
+ * global timeouts (via `timeout` config option).
42
+ * _Breaking change:_ timeout option expects **timeout in seconds**, not in milliseconds as it was previously.
43
+ * test timeouts (via `Scenario` and `Feature` options)
44
+ * _Breaking change:_ `Feature().timeout()` and `Scenario().timeout()` calls has no effect and are deprecated
45
+
46
+ ```js
47
+ // set timeout for every test in suite to 10 secs
48
+ Feature('tests with timeout', { timeout: 10 });
49
+
50
+ // set timeout for this test to 20 secs
51
+ Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {});
52
+ ```
53
+
54
+ * step timeouts (See [#3059](https://github.com/codeceptjs/CodeceptJS/issues/3059) by **[nikocanvacom](https://github.com/nikocanvacom)**)
55
+
56
+ ```js
57
+ // set step timeout to 5 secs
58
+ I.limitTime(5).click('Link');
59
+ ```
60
+ * `stepTimeout` plugin introduced to automatically add timeouts for each step ([#3059](https://github.com/codeceptjs/CodeceptJS/issues/3059) by **[nikocanvacom](https://github.com/nikocanvacom)**).
61
+
62
+ [**retryTo**](/plugins/#retryto) plugin introduced to rerun a set of steps on failure:
63
+
64
+ ```js
65
+ // editing in text in iframe
66
+ // if iframe was not loaded - retry 5 times
67
+ await retryTo(() => {
68
+ I.switchTo('#editor frame');
69
+ I.fillField('textarea', 'value');
70
+ }, 5);
71
+ ```
72
+
73
+ * **[Playwright]** added `locale` configuration
74
+ * **[WebDriver]** upgraded to webdriverio v7
75
+
76
+ 🐛 Bugfixes:
77
+
78
+ * Fixed allure plugin "Unexpected endStep()" error in [#3098](https://github.com/codeceptjs/CodeceptJS/issues/3098) by **[abhimanyupandian](https://github.com/abhimanyupandian)**
79
+ * **[Puppeteer]** always close remote browser on test end. See [#3054](https://github.com/codeceptjs/CodeceptJS/issues/3054) by **[mattonem](https://github.com/mattonem)**
80
+ * stepbyStepReport Plugin: Disabled screenshots after test has failed. See [#3119](https://github.com/codeceptjs/CodeceptJS/issues/3119) by **[ioannisChalkias](https://github.com/ioannisChalkias)**
81
+
82
+
10
83
  ## 3.1.3
11
84
 
12
85
  🛩️ Features:
@@ -24,7 +97,7 @@ Given('I have an employee card', (table) => {
24
97
  // rows = [['Harry', 'Potter', Seeker]];
25
98
  }
26
99
  ```
27
- See updated [BDD section](https://codecept.io/bdd/) for more API options.
100
+ See updated [BDD section](https://codecept.io/bdd/) for more API options. Thanks to **[EgorBodnar](https://github.com/EgorBodnar)**
28
101
 
29
102
  * Support `cjs` file extensions for config file: `codecept.conf.cjs`. See [#3052](https://github.com/codeceptjs/CodeceptJS/issues/3052) by **[kalvenschraut](https://github.com/kalvenschraut)**
30
103
  * API updates: Added `test.file` and `suite.file` properties to `test` and `suite` objects to use in helpers and plugins.
@@ -37,6 +110,7 @@ See updated [BDD section](https://codecept.io/bdd/) for more API options.
37
110
  * **[Playwright]** `I.haveRequestHeaders` affects all tabs. See [#3049](https://github.com/codeceptjs/CodeceptJS/issues/3049) by **[jancorvus](https://github.com/jancorvus)**
38
111
  * BDD: Fixed unhandled empty feature files. Fix [#3046](https://github.com/codeceptjs/CodeceptJS/issues/3046) by **[abhimanyupandian](https://github.com/abhimanyupandian)**
39
112
  * Fixed `RangeError: Invalid string length` in `recorder.js` when running huge amount of tests.
113
+ * **[Appium]** Fixed definitions for `touchPerform`, `hideDeviceKeyboard`, `removeApp` by **[mirao](https://github.com/mirao)**
40
114
 
41
115
  📖 Documentation:
42
116
 
@@ -17,15 +17,15 @@ Here is an overview of available options with their defaults:
17
17
  * **timeout**: `10000` - default tests timeout
18
18
  * **output**: `"./output"` - where to store failure screenshots, etc
19
19
  * **helpers**: `{}` - list of enabled helpers
20
- * **mocha**: `{}` - mocha options, [reporters](http://codecept.io/reports/) can be configured here
21
- * **multiple**: `{}` - multiple options, see [Multiple Execution](http://codecept.io/parallel#multiple-browsers-execution)
22
- * **bootstrap**: `"./bootstrap.js"` - an option to run code _before_ tests are run. See [Hooks](http://codecept.io/hooks/#bootstrap-teardown)).
23
- * **bootstrapAll**: `"./bootstrap.js"` - an option to run code _before_ all test suites are run when using the run-multiple mode. See [Hooks](http://codecept.io/hooks/#bootstrap-teardown)).
24
- * **teardown**: - an option to run code _after_ all test suites are run when using the run-multiple mode. See [Hooks](http://codecept.io/hooks/#bootstrap-teardown).
25
- * **teardownAll**: - an option to run code _after_ tests are run. See [Hooks](http://codecept.io/hooks/#bootstrap-teardown).
20
+ * **mocha**: `{}` - mocha options, [reporters](https://codecept.io/reports/) can be configured here
21
+ * **multiple**: `{}` - multiple options, see [Multiple Execution](https://codecept.io/parallel#multiple-browsers-execution)
22
+ * **bootstrap**: `"./bootstrap.js"` - an option to run code _before_ tests are run. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown)).
23
+ * **bootstrapAll**: `"./bootstrap.js"` - an option to run code _before_ all test suites are run when using the run-multiple mode. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown)).
24
+ * **teardown**: - an option to run code _after_ all test suites are run when using the run-multiple mode. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown).
25
+ * **teardownAll**: - an option to run code _after_ tests are run. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown).
26
26
  * **noGlobals**: `false` - disable registering global variables like `Actor`, `Helper`, `pause`, `within`, `DataTable`
27
- * **hooks**: - include custom listeners to plug into execution workflow. See [Custom Hooks](http://codecept.io/hooks/#custom-hooks)
28
- * **translation**: - [locale](http://codecept.io/translation/) to be used to print s teps output, as well as used in source code.
27
+ * **hooks**: - include custom listeners to plug into execution workflow. See [Custom Hooks](https://codecept.io/hooks/#custom-hooks)
28
+ * **translation**: - [locale](https://codecept.io/translation/) to be used to print s teps output, as well as used in source code.
29
29
  * **require**: `[]` - array of module names to be required before codecept starts. See [Require](#require)
30
30
 
31
31
 
@@ -108,7 +108,7 @@ If you need to get access to web elements, it is recommended to implement operat
108
108
 
109
109
  To get access for elements, connect to a corresponding helper and use `_locate` function to match web elements by CSS or XPath, like you usually do:
110
110
 
111
- ### Acessing Elements in WebDriver
111
+ ### Accessing Elements in WebDriver
112
112
 
113
113
  ```js
114
114
  // inside a custom helper
@@ -264,7 +264,7 @@ class MyHelper extends Helper {
264
264
  const { WebDriver } = this.helpers
265
265
  const { browser } = WebDriver;
266
266
 
267
- // get all cookies according to http://webdriver.io/api/protocol/cookie.html
267
+ // get all cookies according to https://webdriver.io/api/protocol/cookie.html
268
268
  // any helper method should return a value in order to be added to promise chain
269
269
  const res = await browser.cookie();
270
270
  // get values
@@ -304,38 +304,3 @@ class MyHelper extends Helper {
304
304
 
305
305
  module.exports = MyHelper;
306
306
  ```
307
-
308
- ### Protractor Example
309
-
310
- Protractor example demonstrates usage of global `element` and `by` objects.
311
- However `browser` should be accessed from a helper instance via `this.helpers['Protractor']`;
312
- We also use `chai-as-promised` library to have nice assertions with promises.
313
-
314
- ```js
315
- const Helper = require('@codeceptjs/helper');
316
-
317
- // use any assertion library you like
318
- const chai = require('chai');
319
- const chaiAsPromised = require('chai-as-promised');
320
- chai.use(chaiAsPromised);
321
- const expect = chai.expect;
322
-
323
- class MyHelper extends Helper {
324
- /**
325
- * checks that authentication cookie is set
326
- */
327
- seeInHistory(historyPosition, value) {
328
- // access browser instance from Protractor helper
329
- this.helpers['Protractor'].browser.refresh();
330
-
331
- // you can use `element` as well as in protractor
332
- const history = element.all(by.repeater('result in memory'));
333
-
334
- // use chai as promised for better assertions
335
- // end your method with `return` to handle promises
336
- return expect(history.get(historyPosition).getText()).to.eventually.equal(value);
337
- }
338
- }
339
-
340
- module.exports = MyHelper;
341
- ```
package/docs/data.md CHANGED
@@ -5,7 +5,7 @@ title: Data Management
5
5
 
6
6
  # Data Management
7
7
 
8
- > This chapter describes data management for external sources. If you are looking for using Data Sets in tests, see [Data Driven Tests](http://codecept.io/advanced/#data-drivern-tests) section*
8
+ > This chapter describes data management for external sources. If you are looking for using Data Sets in tests, see [Data Driven Tests](https://codecept.io/advanced/#data-drivern-tests) section*
9
9
 
10
10
  Managing data for tests is always a tricky issue. How isolate data between tests, how to prepare data for different tests, etc.
11
11
  There are different approaches to solve it:
@@ -22,7 +22,7 @@ API is supposed to be a stable interface and it can be used by acceptance tests.
22
22
 
23
23
  ## REST
24
24
 
25
- [REST helper](http://codecept.io/helpers/REST/) allows sending raw HTTP requests to application.
25
+ [REST helper](https://codecept.io/helpers/REST/) allows sending raw HTTP requests to application.
26
26
  This is a tool to make shortcuts and create your data pragmatically via API. However, it doesn't provide tools for testing APIs, so it should be paired with WebDriver, Nightmare or Protractor helpers for browser testing.
27
27
 
28
28
  Enable REST helper in the config. It is recommended to set `endpoint`, a base URL for all API requests. If you need some authorization you can optionally set default headers too.
@@ -87,11 +87,11 @@ This can also be used to emulate Ajax requests:
87
87
  I.sendPostRequest('/update-status', {}, { http_x_requested_with: 'xmlhttprequest' });
88
88
  ```
89
89
 
90
- > See complete reference on [REST](http://codecept.io/helpers/REST) helper
90
+ > See complete reference on [REST](https://codecept.io/helpers/REST) helper
91
91
 
92
92
  ## GraphQL
93
93
 
94
- [GraphQL helper](http://codecept.io/helpers/GraphQL/) allows sending GraphQL queries and mutations to application, over Http.
94
+ [GraphQL helper](https://codecept.io/helpers/GraphQL/) allows sending GraphQL queries and mutations to application, over Http.
95
95
  This is a tool to make shortcuts and create your data pragmatically via GraphQL endpoint. However, it doesn't provide tools for testing the endpoint, so it should be paired with WebDriver, Nightmare or Protractor helpers for browser testing.
96
96
 
97
97
  Enable GraphQL helper in the config. It is recommended to set `endpoint`, the URL to which the requests go to. If you need some authorization you can optionally set default headers too.
@@ -160,13 +160,13 @@ After(({ I }) => {
160
160
  });
161
161
  ```
162
162
 
163
- > See complete reference on [GraphQL](http://codecept.io/helpers/GraphQL) helper
163
+ > See complete reference on [GraphQL](https://codecept.io/helpers/GraphQL) helper
164
164
 
165
165
  ## Data Generation with Factories
166
166
 
167
167
  This concept is extended by:
168
- - [ApiDataFactory](http://codecept.io/helpers/ApiDataFactory/) helper, and,
169
- - [GraphQLDataFactory](http://codecept.io/helpers/GraphQLDataFactory/) helper.
168
+ - [ApiDataFactory](https://codecept.io/helpers/ApiDataFactory/) helper, and,
169
+ - [GraphQLDataFactory](https://codecept.io/helpers/GraphQLDataFactory/) helper.
170
170
 
171
171
  These helpers build data according to defined rules and use REST API or GraphQL mutations to store them and automatically clean them up after a test.
172
172
 
@@ -238,7 +238,7 @@ At the end of a test ApiDataFactory will clean up created record for you. This i
238
238
  ids from crated records and running `DELETE /api/users/{id}` requests at the end of a test.
239
239
  This rules can be customized in helper configuration.
240
240
 
241
- > See complete reference on [ApiDataFactory](http://codecept.io/helpers/ApiDataFactory) helper
241
+ > See complete reference on [ApiDataFactory](https://codecept.io/helpers/ApiDataFactory) helper
242
242
 
243
243
  ### GraphQL Data Factory
244
244
 
@@ -303,7 +303,7 @@ data from crated records, creating deletion mutation objects by passing the data
303
303
  This behavior is according the `revert` function be customized in helper configuration.
304
304
  The revert function returns an object, that contains the query for deletion, and the variables object to go along with it.
305
305
 
306
- > See complete reference on [GraphQLDataFactory](http://codecept.io/helpers/GraphQLDataFactory) helper
306
+ > See complete reference on [GraphQLDataFactory](https://codecept.io/helpers/GraphQLDataFactory) helper
307
307
 
308
308
  ## Requests Using Browser Session
309
309