codeceptjs 3.0.3 → 3.0.7

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 (64) hide show
  1. package/CHANGELOG.md +114 -18
  2. package/bin/codecept.js +1 -0
  3. package/docs/basics.md +2 -2
  4. package/docs/bdd.md +12 -1
  5. package/docs/build/Appium.js +2 -1
  6. package/docs/build/GraphQL.js +9 -10
  7. package/docs/build/Nightmare.js +4 -5
  8. package/docs/build/Playwright.js +164 -37
  9. package/docs/build/Protractor.js +1 -1
  10. package/docs/build/Puppeteer.js +1 -1
  11. package/docs/build/REST.js +24 -4
  12. package/docs/build/TestCafe.js +1 -1
  13. package/docs/build/WebDriver.js +85 -17
  14. package/docs/changelog.md +114 -18
  15. package/docs/data.md +5 -5
  16. package/docs/detox.md +2 -2
  17. package/docs/docker.md +11 -11
  18. package/docs/email.md +8 -8
  19. package/docs/helpers/Appium.md +1 -1
  20. package/docs/helpers/Nightmare.md +4 -5
  21. package/docs/helpers/Playwright.md +94 -64
  22. package/docs/helpers/Protractor.md +1 -1
  23. package/docs/helpers/Puppeteer.md +1 -1
  24. package/docs/helpers/REST.md +9 -0
  25. package/docs/helpers/TestCafe.md +1 -1
  26. package/docs/helpers/WebDriver.md +2 -1
  27. package/docs/locators.md +29 -2
  28. package/docs/mobile-react-native-locators.md +2 -2
  29. package/docs/mobile.md +3 -3
  30. package/docs/nightmare.md +0 -5
  31. package/docs/pageobjects.md +3 -1
  32. package/docs/parallel.md +35 -10
  33. package/docs/playwright.md +55 -8
  34. package/docs/plugins.md +73 -29
  35. package/docs/reports.md +8 -7
  36. package/docs/typescript.md +47 -5
  37. package/docs/webapi/fillField.mustache +1 -1
  38. package/lib/cli.js +25 -10
  39. package/lib/codecept.js +9 -1
  40. package/lib/command/interactive.js +10 -9
  41. package/lib/command/run.js +1 -1
  42. package/lib/command/workers/runTests.js +11 -6
  43. package/lib/config.js +8 -3
  44. package/lib/event.js +2 -0
  45. package/lib/helper/Appium.js +1 -0
  46. package/lib/helper/GraphQL.js +9 -10
  47. package/lib/helper/Nightmare.js +1 -1
  48. package/lib/helper/Playwright.js +131 -38
  49. package/lib/helper/REST.js +24 -4
  50. package/lib/helper/WebDriver.js +84 -16
  51. package/lib/interfaces/gherkin.js +11 -4
  52. package/lib/output.js +7 -4
  53. package/lib/plugin/allure.js +3 -7
  54. package/lib/plugin/fakerTransform.js +51 -0
  55. package/lib/plugin/screenshotOnFail.js +6 -2
  56. package/lib/recorder.js +9 -0
  57. package/lib/step.js +2 -1
  58. package/lib/transform.js +26 -0
  59. package/lib/ui.js +6 -2
  60. package/lib/within.js +1 -1
  61. package/lib/workers.js +39 -25
  62. package/package.json +14 -9
  63. package/typings/index.d.ts +49 -21
  64. package/typings/types.d.ts +72 -26
package/CHANGELOG.md CHANGED
@@ -1,26 +1,122 @@
1
+ ## 3.0.7
2
+
3
+ Documentation fixes:
4
+ * Remove broken link from `Nightmare helper`. See #2860 by @Arhell
5
+ * Fixed broken links in `playwright.md`. See #2848 by @johnhoodjr
6
+ * Fix mocha-multi config example. See #2881 by @rimesc
7
+ * Fix small errors in email documentation file. See #2884 by @mkrtchian
8
+ * Improve documentation for `Sharing Data Between Workers` section. See #2891 by @ngraf
9
+
10
+ Features:
11
+ * [WebDriver] Shadow DOM Support for `Webdriver`. See #2741 by @gkushang
12
+ * [Release management] Introduce the versioning automatically, it follows the semantics versioning. See #2883 by @PeterNgTr
13
+ * Adding opts into `Scenario.skip` that it would be useful for building reports. See #2867 by @AlexKo4
14
+ * Added support for attaching screenshots to [cucumberJsonReporter](https://github.com/ktryniszewski-mdsol/codeceptjs-cucumber-json-reporter) See #2888 by @fijijavis
15
+ * Supported config file for `codeceptjs shell` command. See #2895 by @PeterNgTr:
16
+
17
+ ```
18
+ npx codeceptjs shell -c foo.conf.js
19
+ ```
20
+
21
+ Bug fixes:
22
+ * [GraphQL] Use a helper-specific instance of Axios to avoid contaminating global defaults. See #2868 by @vanvoljg
23
+ * A default system color is used when passing non supported system color when using I.say(). See #2874 by @PeterNgTr
24
+ * [Playwright] Avoid the timout due to calling the click on invisible elements. See #2875 by cbayer97
25
+
26
+
27
+ ## 3.0.6
28
+
29
+ * [Playwright] Added `electron` as a browser to config. See #2834 by @cbayer97
30
+ * [Playwright] Implemented `launchPersistentContext` to be able to launch persistent remote browsers. See #2817 by @brunoqueiros. Fixes #2376.
31
+ * Fixed printing logs and stack traces for `run-workers`. See #2857 by @haveac1gar. Fixes #2621, #2852
32
+ * Emit custom messages from worker to the main thread. See #2824 by @jccguimaraes
33
+ * Improved workers processes output. See #2804 by @drfiresign
34
+ * BDD. Added ability to use an array of feature files inside config in `gherkin.features`. See #2814 by @jbergeronjr
35
+
36
+ ```js
37
+ "features": [
38
+ "./features/*.feature",
39
+ "./features/api_features/*.feature"
40
+ ],
41
+ ```
42
+ * Added `getQueueId` to reporter to rerun a specific promise. See #2837 by @jonatask
43
+ * **Added `fakerTransform` plugin** to use faker data in Gherkin scenarios. See #2854 by @adrielcodeco
44
+
45
+ ```feature
46
+ Scenario Outline: ...
47
+ Given ...
48
+ When ...
49
+ Then ...
50
+
51
+ Examples:
52
+ | productName | customer | email | anythingMore |
53
+ | {{commerce.product}} | Dr. {{name.findName}} | {{internet.email}} | staticData |
54
+ ```
55
+ * [REST] Use class instance of axios, not the global instance, to avoid contaminating global configuration. #2846 by @vanvoljg
56
+ * [Appium] Added `tunnelIdentifier` config option to provide tunnel for SauceLabs. See #2832 by @gurjeetbains
57
+
58
+ ## 3.0.5
59
+
60
+
61
+ Features:
62
+
63
+ * **[Official Docker image for CodeceptJS v3](https://hub.docker.com/r/codeceptjs/codeceptjs)**. New Docker image is based on official Playwright image and supports Playwright, Puppeteer, WebDriver engines. Thanks @VikentyShevyrin
64
+ * Better support for Typescript `codecept.conf.ts` configuration files. See #2750 by @elaichenkov
65
+ * Propagate more events for custom parallel script. See #2796 by @jccguimaraes
66
+ * [mocha-junit-reporter] Now supports attachments, see documentation for details. See #2675 by @Shard
67
+ * CustomLocators interface for TypeScript to extend from LocatorOrString. See #2798 by @danielrentz
68
+ * [REST] Mask sensitive data from log messages.
69
+ ```js
70
+ I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" }));
71
+ ```
72
+ See #2786 by @PeterNgTr
73
+
74
+ Bug fixes:
75
+ * Fixed reporting of nested steps with PageObjects and BDD scenarios. See #2800 by @davertmik. Fixes #2720 #2682
76
+ * Fixed issue with `codeceptjs shell` which was broken since 3.0.0. See #2743 by @stedman
77
+ * [Gherkin] Fixed issue suppressed or hidden errors in tests. See #2745 by @ktryniszewski-mdsol
78
+ * [Playwright] fix grabCssPropertyFromAll serialization by using property names. See #2757 by @elaichenkov
79
+ * [Allure] fix report for multi sessions. See #2771 by @cbayer97
80
+ * [WebDriver] Fix locator object debug log messages in smart wait. See 2748 by @elaichenkov
81
+
82
+ Documentation fixes:
83
+ * Fixed some broken examples. See #2756 by @danielrentz
84
+ * Fixed Typescript typings. See #2747, #2758 and #2769 by @elaichenkov
85
+ * Added missing type for xFeature. See #2754 by @PeterNgTr
86
+ * Fixed code example in Page Object documentation. See #2793 by @mkrtchian
87
+
88
+ Library updates:
89
+ * Updated Axios to 0.21.1. See by @sseide
90
+ * Updated @pollyjs/core @pollyjs/adapter-puppeteer. See #2760 by @Anikethana
91
+
92
+ ## 3.0.4
93
+
94
+ * **Hotfix** Fixed `init` script by adding `cross-spawn` package. By @vipulgupta2048
95
+ * Fixed handling error during initialization of `run-multiple`. See #2730 by @wagoid
96
+
1
97
  ## 3.0.3
2
98
 
3
99
  * **Playwright 1.7 support**
4
- * [Playwright] Fixed handling null context in click. See #2667 by @matthewjf
5
- * [Playwright] Fixed `Cannot read property '$$' of null` when locating elements. See #2713 by @matthewjf
100
+ * [Playwright] Fixed handling null context in click. See #2667 by @matthewjf
101
+ * [Playwright] Fixed `Cannot read property '$$' of null` when locating elements. See #2713 by @matthewjf
6
102
  * Command `npx codeceptjs init` improved
7
103
  * auto-installing required packages
8
104
  * better error messages
9
105
  * fixed generating type definitions
10
- * Data Driven Tests improvements: instead of having one skipped test for data driven scenarios when using xData you get a skipped test for each entry in the data table. See #2698 by @Georgegriff
11
- * [Puppeteer] Fixed that `waitForFunction` was not working with number values. See #2703 by @MumblesNZ
106
+ * Data Driven Tests improvements: instead of having one skipped test for data driven scenarios when using xData you get a skipped test for each entry in the data table. See #2698 by @Georgegriff
107
+ * [Puppeteer] Fixed that `waitForFunction` was not working with number values. See #2703 by @MumblesNZ
12
108
  * Enabled autocompletion for custom helpers. #2695 by @PeterNgTr
13
109
  * Emit test.after on workers. Fix #2693 by @jccguimaraes
14
- * TypeScript: Allow .ts config files. See #2708 by @elukoyanov
110
+ * TypeScript: Allow .ts config files. See #2708 by @elukoyanov
15
111
  * Fixed definitions generation errors by @elukoyanov. See #2707 and #2718
16
112
  * Fixed handing error in _after function; for example, browser is closed during test and tests executions is stopped, but error was not logged. See #2715 by @elukoyanov
17
113
  * Emit hook.failed in workers. Fix #2723 by @jccguimaraes
18
- * [wdio plugin] Added `seleniumArgs` and `seleniumInstallArgs` config options for plugin. See #2687 by @andrerleao
114
+ * [wdio plugin] Added `seleniumArgs` and `seleniumInstallArgs` config options for plugin. See #2687 by @andrerleao
19
115
  * [allure plugin] Added `addParameter` method in #2717 by @jancorvus. Fixes #2716
20
- * Added mocha-based `--reporter-options` and `--reporter <name>` commands to `run-workers` command by in #2691 @Ameterezu
21
- * Fixed infinite loop for junit reports. See #2691 @Ameterezu
22
- * Added status, start/end time, and match line for BDD steps. See #2678 by @ktryniszewski-mdsol
23
- * [stepByStepReport plugin] Fixed "helper.saveScreenshot is not a function". Fix #2688 by @andrerleao
116
+ * Added mocha-based `--reporter-options` and `--reporter <name>` commands to `run-workers` command by in #2691 @Ameterezu
117
+ * Fixed infinite loop for junit reports. See #2691 @Ameterezu
118
+ * Added status, start/end time, and match line for BDD steps. See #2678 by @ktryniszewski-mdsol
119
+ * [stepByStepReport plugin] Fixed "helper.saveScreenshot is not a function". Fix #2688 by @andrerleao
24
120
 
25
121
 
26
122
 
@@ -28,21 +124,21 @@
28
124
 
29
125
  * [Playwright] Fix connection close with remote browser. See #2629 by @dipiash
30
126
  * [REST] set maxUploadFileSize when performing api calls. See #2611 by @PeterNgTr
31
- * Duplicate Scenario names (combined with Feature name) are now detected via a warning message.
127
+ * Duplicate Scenario names (combined with Feature name) are now detected via a warning message.
32
128
  Duplicate test names can cause `codeceptjs run-workers` to not function. See #2656 by @Georgegriff
33
129
  * Documentation fixes
34
130
 
35
131
  Bug Fixes:
36
132
  * --suites flag now should function correctly for `codeceptjs run-workers`. See #2655 by @Georgegriff
37
133
  * [autoLogin plugin] Login methods should now function as expected with `codeceptjs run-workers`. See #2658 by @Georgegriff, resolves #2620
38
-
134
+
39
135
 
40
136
 
41
137
  ## 3.0.1
42
138
 
43
139
  ♨️ Hot fix:
44
140
  * Lock the mocha version to avoid the errors. See #2624 by PeterNgTr
45
-
141
+
46
142
  🐛 Bug Fix:
47
143
  * Fixed error handling in Scenario.js. See #2607 by haveac1gar
48
144
  * Changing type definition in order to allow the use of functions with any number of any arguments. See #2616 by akoltun
@@ -65,9 +161,9 @@ Scenario('title', (I, loginPage) => {});
65
161
  Scenario('title', ({ I, loginPage }) => {});
66
162
  ```
67
163
 
68
- * **BREAKING** Replaced bootstrap/teardown scripts to accept only functions or async functions. Async function with callback (with done parameter) should be replaced with async/await. [See our upgrde guide](https://bit.ly/codecept3Up).
164
+ * **BREAKING** Replaced bootstrap/teardown scripts to accept only functions or async functions. Async function with callback (with done parameter) should be replaced with async/await. [See our upgrade guide](https://bit.ly/codecept3Up).
69
165
  * **[TypeScript guide](/typescript)** and [boilerplate project](https://github.com/codeceptjs/typescript-boilerplate)
70
- * [tryTo](/plugins/#tryTo) and [pauseOnFail](/plugins/#pauseOnFail) plugins installed by default
166
+ * [tryTo](/plugins/#tryto) and [pauseOnFail](/plugins/#pauseOnFail) plugins installed by default
71
167
  * Introduced one-line installer:
72
168
 
73
169
  ```
@@ -193,9 +289,9 @@ tryTo(() => I.click('Accept', '.cookies'));
193
289
  ## 2.6.11
194
290
 
195
291
  * [Playwright] Playwright 1.4 compatibility
196
- * [Playwright] Added `ignoreHTTPSErrors` config option (default: false). See #2566 by gurjeetbains
197
- * Added French translation by @vimar
198
- * [WebDriver] Updated `dragSlider` to work in WebDriver W3C protocol. Fixes #2557 by suniljaiswal01
292
+ * [Playwright] Added `ignoreHTTPSErrors` config option (default: false). See #2566 by gurjeetbains
293
+ * Added French translation by @vimar
294
+ * [WebDriver] Updated `dragSlider` to work in WebDriver W3C protocol. Fixes #2557 by suniljaiswal01
199
295
 
200
296
  ## 2.6.10
201
297
 
package/bin/codecept.js CHANGED
@@ -27,6 +27,7 @@ program.command('shell [path]')
27
27
  .description('Interactive shell')
28
28
  .option('--verbose', 'output internal logging information')
29
29
  .option('--profile [value]', 'configuration profile to be used')
30
+ .option('-c, --config [file]', 'configuration file to be used')
30
31
  .action(require('../lib/command/interactive'));
31
32
 
32
33
  program.command('list [path]')
package/docs/basics.md CHANGED
@@ -30,7 +30,7 @@ The following is a diagram of the CodeceptJS architecture:
30
30
  ![architecture](/img/architecture.svg)
31
31
 
32
32
  All helpers share the same API, so it's easy to migrate tests from one backend to another.
33
- However, because of the difference in backends and their limitations, they are not guaranteed to be compatible with each other. For instance, you can't set request headers in WebDriver or Protractor, but you can do so in Puppteer or Nightmare.
33
+ However, because of the difference in backends and their limitations, they are not guaranteed to be compatible with each other. For instance, you can't set request headers in WebDriver or Protractor, but you can do so in Puppeteer or Nightmare.
34
34
 
35
35
  **Pick one helper, as it defines how tests are executed.** If requirements change it's easy to migrate to another.
36
36
 
@@ -697,7 +697,7 @@ You may also use `tryTo` for cases when you deal with uncertainty on page:
697
697
  * soft assertions
698
698
  * cookies & gdpr
699
699
 
700
- `tryTo` function is enabled by default via [tryTo plugin](/plugins#tryTo)
700
+ `tryTo` function is enabled by default via [tryTo plugin](/plugins/#tryto)
701
701
 
702
702
  ## Comments
703
703
 
package/docs/bdd.md CHANGED
@@ -343,7 +343,7 @@ Tag should be placed before *Scenario:* or before *Feature:* keyword. In the las
343
343
  ## Configuration
344
344
 
345
345
  * `gherkin`
346
- * `features` - path to feature files
346
+ * `features` - path to feature files, or an array of feature file paths
347
347
  * `steps` - array of files with step definitions
348
348
 
349
349
  ```js
@@ -354,6 +354,17 @@ Tag should be placed before *Scenario:* or before *Feature:* keyword. In the las
354
354
  ]
355
355
  }
356
356
  ```
357
+ ```js
358
+ "gherkin": {
359
+ "features": [
360
+ "./features/*.feature",
361
+ "./features/api_features/*.feature"
362
+ ],
363
+ "steps": [
364
+ "./step_definitions/steps.js"
365
+ ]
366
+ }
367
+ ```
357
368
 
358
369
  ## Before
359
370
 
@@ -183,6 +183,7 @@ class Appium extends Webdriver {
183
183
  config.capabilities.browserName = config.browser || config.capabilities.browserName;
184
184
  config.capabilities.app = config.app || config.capabilities.app;
185
185
  config.capabilities.platformName = config.platform || config.capabilities.platformName;
186
+ config.capabilities.tunnelIdentifier = config.tunnelIdentifier || config.capabilities.tunnelIdentifier; // Adding the code to connect to sauce labs via sauce tunnel
186
187
  config.waitForTimeout /= 1000; // convert to seconds
187
188
 
188
189
  // [CodeceptJS compatible] transform host to hostname
@@ -1414,7 +1415,7 @@ class Appium extends Webdriver {
1414
1415
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
1415
1416
  * ```
1416
1417
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1417
- * @param {string} value text value to fill.
1418
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
1418
1419
  *
1419
1420
  *
1420
1421
  */
@@ -1,8 +1,6 @@
1
- let axios = require('axios');
1
+ const axios = require('axios').default;
2
2
  const Helper = require('../helper');
3
3
 
4
- let headers = {};
5
-
6
4
  /**
7
5
  * GraphQL helper allows to send additional requests to a GraphQl endpoint during acceptance tests.
8
6
  * [Axios](https://github.com/axios/axios) library is used to perform requests.
@@ -41,15 +39,16 @@ let headers = {};
41
39
  class GraphQL extends Helper {
42
40
  constructor(config) {
43
41
  super(config);
44
- axios = require('axios');
42
+ this.axios = axios.create();
43
+ this.headers = {};
45
44
  this.options = {
46
45
  timeout: 10000,
47
46
  defaultHeaders: {},
48
47
  endpoint: '',
49
48
  };
50
49
  this.options = Object.assign(this.options, config);
51
- headers = { ...this.options.defaultHeaders };
52
- axios.defaults.headers = this.options.defaultHeaders;
50
+ this.headers = { ...this.options.defaultHeaders };
51
+ this.axios.defaults.headers = this.options.defaultHeaders;
53
52
  }
54
53
 
55
54
  static _checkRequirements() {
@@ -66,10 +65,10 @@ class GraphQL extends Helper {
66
65
  * @param {object} request
67
66
  */
68
67
  async _executeQuery(request) {
69
- axios.defaults.timeout = request.timeout || this.options.timeout;
68
+ this.axios.defaults.timeout = request.timeout || this.options.timeout;
70
69
 
71
- if (headers && headers.auth) {
72
- request.auth = headers.auth;
70
+ if (this.headers && this.headers.auth) {
71
+ request.auth = this.headers.auth;
73
72
  }
74
73
 
75
74
  request.headers = Object.assign(request.headers, {
@@ -84,7 +83,7 @@ class GraphQL extends Helper {
84
83
 
85
84
  let response;
86
85
  try {
87
- response = await axios(request);
86
+ response = await this.axios(request);
88
87
  } catch (err) {
89
88
  if (!err.response) throw err;
90
89
  this.debugSection(
@@ -966,7 +966,7 @@ class Nightmare extends Helper {
966
966
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
967
967
  * ```
968
968
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
969
- * @param {string} value text value to fill.
969
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
970
970
  *
971
971
  */
972
972
  async fillField(field, value) {
@@ -1180,15 +1180,14 @@ class Nightmare extends Helper {
1180
1180
  }
1181
1181
 
1182
1182
  /**
1183
- * Retrieves a value from a form element located by CSS or XPath and returns it to test.
1183
+ * Retrieves an array of value from a form located by CSS or XPath and returns it to test.
1184
1184
  * Resumes test execution, so **should be used inside async function with `await`** operator.
1185
- * If more than one element is found - value of first element is returned.
1186
1185
  *
1187
1186
  * ```js
1188
- * let email = await I.grabValueFrom('input[name=email]');
1187
+ * let inputs = await I.grabValueFromAll('//form/input');
1189
1188
  * ```
1190
1189
  * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
1191
- * @returns {Promise<string>} attribute value
1190
+ * @returns {Promise<string[]>} attribute value
1192
1191
  *
1193
1192
  */
1194
1193
  async grabValueFromAll(locator) {