codeceptjs 3.0.3-beta.7 → 3.0.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 (50) hide show
  1. package/CHANGELOG.md +71 -6
  2. package/docs/build/Appium.js +1 -1
  3. package/docs/build/Nightmare.js +4 -5
  4. package/docs/build/Playwright.js +75 -24
  5. package/docs/build/Protractor.js +1 -1
  6. package/docs/build/Puppeteer.js +3 -3
  7. package/docs/build/REST.js +20 -1
  8. package/docs/build/TestCafe.js +1 -1
  9. package/docs/build/WebDriver.js +3 -3
  10. package/docs/changelog.md +71 -6
  11. package/docs/data.md +5 -5
  12. package/docs/detox.md +2 -2
  13. package/docs/docker.md +11 -11
  14. package/docs/examples.md +4 -4
  15. package/docs/helpers/Appium.md +1 -1
  16. package/docs/helpers/Nightmare.md +4 -5
  17. package/docs/helpers/Playwright.md +81 -61
  18. package/docs/helpers/Protractor.md +1 -1
  19. package/docs/helpers/Puppeteer.md +1 -1
  20. package/docs/helpers/REST.md +9 -0
  21. package/docs/helpers/TestCafe.md +1 -1
  22. package/docs/helpers/WebDriver.md +1 -1
  23. package/docs/locators.md +2 -2
  24. package/docs/mobile-react-native-locators.md +2 -2
  25. package/docs/mobile.md +3 -3
  26. package/docs/pageobjects.md +3 -1
  27. package/docs/reports.md +3 -3
  28. package/docs/typescript.md +47 -5
  29. package/docs/webapi/fillField.mustache +1 -1
  30. package/lib/cli.js +16 -10
  31. package/lib/command/init.js +15 -7
  32. package/lib/command/interactive.js +6 -7
  33. package/lib/command/run.js +1 -1
  34. package/lib/config.js +6 -1
  35. package/lib/container.js +1 -1
  36. package/lib/helper/Nightmare.js +1 -1
  37. package/lib/helper/Playwright.js +40 -24
  38. package/lib/helper/REST.js +20 -1
  39. package/lib/helper/WebDriver.js +2 -2
  40. package/lib/interfaces/gherkin.js +17 -3
  41. package/lib/output.js +2 -2
  42. package/lib/plugin/allure.js +3 -7
  43. package/lib/plugin/autoDelay.js +1 -1
  44. package/lib/plugin/screenshotOnFail.js +1 -2
  45. package/lib/step.js +2 -1
  46. package/lib/within.js +1 -1
  47. package/lib/workers.js +13 -1
  48. package/package.json +6 -6
  49. package/typings/index.d.ts +7 -2
  50. package/typings/types.d.ts +55 -21
package/CHANGELOG.md CHANGED
@@ -1,22 +1,87 @@
1
+ ## 3.0.5
2
+
3
+
4
+ Features:
5
+
6
+ * **[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
7
+ * Better support for Typescript `codecept.conf.ts` configuration files. See #2750 by @elaichenkov
8
+ * Propagate more events for custom parallel script. See #2796 by @jccguimaraes
9
+ * [mocha-junit-reporter] Now supports attachments, see documentation for details. See #2675 by @Shard
10
+ * CustomLocators interface for TypeScript to extend from LocatorOrString. See #2798 by @danielrentz
11
+ * [REST] Mask sensitive data from log messages.
12
+ ```js
13
+ I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" }));
14
+ ```
15
+ See #2786 by @PeterNgTr
16
+
17
+ Bug fixes:
18
+ * Fixed reporting of nested steps with PageObjects and BDD scenarios. See #2800 by @davertmik. Fixes #2720 #2682
19
+ * Fixed issue with `codeceptjs shell` which was broken since 3.0.0. See #2743 by @stedman
20
+ * [Gherkin] Fixed issue suppressed or hidden errors in tests. See #2745 by @ktryniszewski-mdsol
21
+ * [Playwright] fix grabCssPropertyFromAll serialization by using property names. See #2757 by @elaichenkov
22
+ * [Allure] fix report for multi sessions. See #2771 by @cbayer97
23
+ * [WebDriver] Fix locator object debug log messages in smart wait. See 2748 by @elaichenkov
24
+
25
+ Documentation fixes:
26
+ * Fixed some broken examples. See #2756 by @danielrentz
27
+ * Fixed Typescript typings. See #2747, #2758 and #2769 by @elaichenkov
28
+ * Added missing type for xFeature. See #2754 by @PeterNgTr
29
+ * Fixed code example in Page Object documentation. See #2793 by @mkrtchian
30
+
31
+ Library updates:
32
+ * Updated Axios to 0.21.1. See by @sseide
33
+ * Updated @pollyjs/core @pollyjs/adapter-puppeteer. See #2760 by @Anikethana
34
+
35
+ ## 3.0.4
36
+
37
+ * **Hotfix** Fixed `init` script by adding `cross-spawn` package. By @vipulgupta2048
38
+ * Fixed handling error during initialization of `run-multiple`. See #2730 by @wagoid
39
+
40
+ ## 3.0.3
41
+
42
+ * **Playwright 1.7 support**
43
+ * [Playwright] Fixed handling null context in click. See #2667 by @matthewjf
44
+ * [Playwright] Fixed `Cannot read property '$$' of null` when locating elements. See #2713 by @matthewjf
45
+ * Command `npx codeceptjs init` improved
46
+ * auto-installing required packages
47
+ * better error messages
48
+ * fixed generating type definitions
49
+ * 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
50
+ * [Puppeteer] Fixed that `waitForFunction` was not working with number values. See #2703 by @MumblesNZ
51
+ * Enabled autocompletion for custom helpers. #2695 by @PeterNgTr
52
+ * Emit test.after on workers. Fix #2693 by @jccguimaraes
53
+ * TypeScript: Allow .ts config files. See #2708 by @elukoyanov
54
+ * Fixed definitions generation errors by @elukoyanov. See #2707 and #2718
55
+ * 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
56
+ * Emit hook.failed in workers. Fix #2723 by @jccguimaraes
57
+ * [wdio plugin] Added `seleniumArgs` and `seleniumInstallArgs` config options for plugin. See #2687 by @andrerleao
58
+ * [allure plugin] Added `addParameter` method in #2717 by @jancorvus. Fixes #2716
59
+ * Added mocha-based `--reporter-options` and `--reporter <name>` commands to `run-workers` command by in #2691 @Ameterezu
60
+ * Fixed infinite loop for junit reports. See #2691 @Ameterezu
61
+ * Added status, start/end time, and match line for BDD steps. See #2678 by @ktryniszewski-mdsol
62
+ * [stepByStepReport plugin] Fixed "helper.saveScreenshot is not a function". Fix #2688 by @andrerleao
63
+
64
+
65
+
1
66
  ## 3.0.2
2
67
 
3
68
  * [Playwright] Fix connection close with remote browser. See #2629 by @dipiash
4
69
  * [REST] set maxUploadFileSize when performing api calls. See #2611 by @PeterNgTr
5
- * Duplicate Scenario names (combined with Feature name) are now detected via a warning message.
70
+ * Duplicate Scenario names (combined with Feature name) are now detected via a warning message.
6
71
  Duplicate test names can cause `codeceptjs run-workers` to not function. See #2656 by @Georgegriff
7
72
  * Documentation fixes
8
73
 
9
74
  Bug Fixes:
10
75
  * --suites flag now should function correctly for `codeceptjs run-workers`. See #2655 by @Georgegriff
11
76
  * [autoLogin plugin] Login methods should now function as expected with `codeceptjs run-workers`. See #2658 by @Georgegriff, resolves #2620
12
-
77
+
13
78
 
14
79
 
15
80
  ## 3.0.1
16
81
 
17
82
  ♨️ Hot fix:
18
83
  * Lock the mocha version to avoid the errors. See #2624 by PeterNgTr
19
-
84
+
20
85
  🐛 Bug Fix:
21
86
  * Fixed error handling in Scenario.js. See #2607 by haveac1gar
22
87
  * Changing type definition in order to allow the use of functions with any number of any arguments. See #2616 by akoltun
@@ -167,9 +232,9 @@ tryTo(() => I.click('Accept', '.cookies'));
167
232
  ## 2.6.11
168
233
 
169
234
  * [Playwright] Playwright 1.4 compatibility
170
- * [Playwright] Added `ignoreHTTPSErrors` config option (default: false). See #2566 by gurjeetbains
171
- * Added French translation by @vimar
172
- * [WebDriver] Updated `dragSlider` to work in WebDriver W3C protocol. Fixes #2557 by suniljaiswal01
235
+ * [Playwright] Added `ignoreHTTPSErrors` config option (default: false). See #2566 by gurjeetbains
236
+ * Added French translation by @vimar
237
+ * [WebDriver] Updated `dragSlider` to work in WebDriver W3C protocol. Fixes #2557 by suniljaiswal01
173
238
 
174
239
  ## 2.6.10
175
240
 
@@ -1414,7 +1414,7 @@ class Appium extends Webdriver {
1414
1414
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
1415
1415
  * ```
1416
1416
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1417
- * @param {string} value text value to fill.
1417
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
1418
1418
  *
1419
1419
  *
1420
1420
  */
@@ -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) {
@@ -495,7 +495,7 @@ class Playwright extends Helper {
495
495
  this.page = page;
496
496
  if (!page) return;
497
497
  page.setDefaultNavigationTimeout(this.options.getPageTimeout);
498
- this.context = await this.page.$('body');
498
+ this.context = await this.page;
499
499
  if (this.config.browser === 'chrome') {
500
500
  await page.bringToFront();
501
501
  }
@@ -624,7 +624,7 @@ class Playwright extends Helper {
624
624
 
625
625
  async _withinEnd() {
626
626
  this.withinLocator = null;
627
- this.context = await this.page.mainFrame().$('body');
627
+ this.context = await this.page;
628
628
  }
629
629
 
630
630
  _extractDataFromPerformanceTiming(timing, ...dataNames) {
@@ -878,11 +878,14 @@ class Playwright extends Helper {
878
878
  }
879
879
 
880
880
  /**
881
- * Checks that title is equal to provided one.
882
- *
883
- * ```js
884
- * I.seeTitleEquals('Test title.');
885
- * ```
881
+ * Checks that title is equal to provided one.
882
+ *
883
+ * ```js
884
+ * I.seeTitleEquals('Test title.');
885
+ * ```
886
+ *
887
+ * @param {string} text value to check.
888
+ *
886
889
  */
887
890
  async seeTitleEquals(text) {
888
891
  const title = await this.page.title();
@@ -928,7 +931,8 @@ class Playwright extends Helper {
928
931
  *
929
932
  */
930
933
  async _locate(locator) {
931
- return findElements(await this.context, locator);
934
+ const context = await this.context || await this._getContext();
935
+ return findElements(context, locator);
932
936
  }
933
937
 
934
938
  /**
@@ -1216,14 +1220,34 @@ class Playwright extends Helper {
1216
1220
  }
1217
1221
 
1218
1222
  /**
1219
- *
1220
- * Force clicks an element without waiting for it to become visible and not animating.
1221
- *
1223
+ * Perform an emulated click on a link or a button, given by a locator.
1224
+ * Unlike normal click instead of sending native event, emulates a click with JavaScript.
1225
+ * This works on hidden, animated or inactive elements as well.
1226
+ *
1227
+ * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
1228
+ * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
1229
+ * For images, the "alt" attribute and inner text of any parent links are searched.
1230
+ *
1231
+ * The second parameter is a context (CSS or XPath locator) to narrow the search.
1232
+ *
1222
1233
  * ```js
1223
- * I.forceClick('#hiddenButton');
1224
- * I.forceClick('Click me', '#hidden');
1234
+ * // simple link
1235
+ * I.forceClick('Logout');
1236
+ * // button of form
1237
+ * I.forceClick('Submit');
1238
+ * // CSS button
1239
+ * I.forceClick('#form input[type=submit]');
1240
+ * // XPath
1241
+ * I.forceClick('//form/*[@type=submit]');
1242
+ * // link in context
1243
+ * I.forceClick('Logout', '#nav');
1244
+ * // using strict locator
1245
+ * I.forceClick({css: 'nav a.login'});
1225
1246
  * ```
1226
- *
1247
+ *
1248
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1249
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1250
+ *
1227
1251
  */
1228
1252
  async forceClick(locator, context = null) {
1229
1253
  return proceedClick.call(this, locator, context, { force: true });
@@ -1529,7 +1553,7 @@ class Playwright extends Helper {
1529
1553
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
1530
1554
  * ```
1531
1555
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1532
- * @param {string} value text value to fill.
1556
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
1533
1557
  *
1534
1558
  *
1535
1559
  */
@@ -2042,6 +2066,10 @@ class Playwright extends Helper {
2042
2066
  * I.executeScript(([x, y]) => x + y, [x, y]);
2043
2067
  * ```
2044
2068
  * If a function returns a Promise it will wait for its resolution.
2069
+ *
2070
+ * @param {string|function} fn function to be executed in browser context.
2071
+ * @param {any} [arg] optional argument to pass to the function
2072
+ * @return {Promise<any>}
2045
2073
  */
2046
2074
  async executeScript(fn, arg) {
2047
2075
  let context = this.page;
@@ -2208,8 +2236,7 @@ class Playwright extends Helper {
2208
2236
  async grabCssPropertyFromAll(locator, cssProperty) {
2209
2237
  const els = await this._locate(locator);
2210
2238
  this.debug(`Matched ${els.length} elements`);
2211
- const res = await Promise.all(els.map(el => el.$eval('xpath=.', el => JSON.parse(JSON.stringify(getComputedStyle(el))), el)));
2212
- const cssValues = res.map(props => props[toCamelCase(cssProperty)]);
2239
+ const cssValues = await Promise.all(els.map(el => el.$eval('xpath=.', (el, cssProperty) => getComputedStyle(el).getPropertyValue(cssProperty), cssProperty)));
2213
2240
 
2214
2241
  return cssValues;
2215
2242
  }
@@ -2460,9 +2487,21 @@ class Playwright extends Helper {
2460
2487
  async waitForEnabled(locator, sec) {
2461
2488
  const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
2462
2489
  locator = new Locator(locator, 'css');
2490
+ const matcher = await this.context;
2491
+ let waiter;
2463
2492
  const context = await this._getContext();
2464
- // playwright combined selectors
2465
- const waiter = context.waitForSelector(`${buildLocatorString(locator)} >> __disabled=false`, { timeout: waitTimeout });
2493
+ if (!locator.isXPath()) {
2494
+ const valueFn = function ([locator]) {
2495
+ return Array.from(document.querySelectorAll(locator)).filter(el => !el.disabled).length > 0;
2496
+ };
2497
+ waiter = context.waitForFunction(valueFn, [locator.value], { timeout: waitTimeout });
2498
+ } else {
2499
+ const enabledFn = function ([locator, $XPath]) {
2500
+ eval($XPath); // eslint-disable-line no-eval
2501
+ return $XPath(null, locator).filter(el => !el.disabled).length > 0;
2502
+ };
2503
+ waiter = context.waitForFunction(enabledFn, [locator.value, $XPath.toString()], { timeout: waitTimeout });
2504
+ }
2466
2505
  return waiter.catch((err) => {
2467
2506
  throw new Error(`element (${locator.toString()}) still not enabled after ${waitTimeout / 1000} sec\n${err.message}`);
2468
2507
  });
@@ -2483,9 +2522,21 @@ class Playwright extends Helper {
2483
2522
  async waitForValue(field, value, sec) {
2484
2523
  const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
2485
2524
  const locator = new Locator(field, 'css');
2525
+ const matcher = await this.context;
2526
+ let waiter;
2486
2527
  const context = await this._getContext();
2487
- // uses a custom selector engine for finding value properties on elements
2488
- const waiter = context.waitForSelector(`${buildLocatorString(locator)} >> __value=${value}`, { timeout: waitTimeout, state: 'visible' });
2528
+ if (!locator.isXPath()) {
2529
+ const valueFn = function ([locator, value]) {
2530
+ return Array.from(document.querySelectorAll(locator)).filter(el => (el.value || '').indexOf(value) !== -1).length > 0;
2531
+ };
2532
+ waiter = context.waitForFunction(valueFn, [locator.value, value], { timeout: waitTimeout });
2533
+ } else {
2534
+ const valueFn = function ([locator, $XPath, value]) {
2535
+ eval($XPath); // eslint-disable-line no-eval
2536
+ return $XPath(null, locator).filter(el => (el.value || '').indexOf(value) !== -1).length > 0;
2537
+ };
2538
+ waiter = context.waitForFunction(valueFn, [locator.value, $XPath.toString(), value], { timeout: waitTimeout });
2539
+ }
2489
2540
  return waiter.catch((err) => {
2490
2541
  const loc = locator.toString();
2491
2542
  throw new Error(`element (${loc}) is not in DOM or there is no element(${loc}) with value "${value}" after ${waitTimeout / 1000} sec\n${err.message}`);
@@ -2805,7 +2856,7 @@ class Playwright extends Helper {
2805
2856
  return;
2806
2857
  }
2807
2858
  if (!locator) {
2808
- this.context = await this.page.mainFrame().$('body');
2859
+ this.context = this.page;
2809
2860
  return;
2810
2861
  }
2811
2862
 
@@ -2857,7 +2908,7 @@ class Playwright extends Helper {
2857
2908
  /**
2858
2909
  * Waits for navigation to finish. By default takes configured `waitForNavigation` option.
2859
2910
  *
2860
- * See [Pupeteer's reference](https://github.com/microsoft/Playwright/blob/master/docs/api.md#pagewaitfornavigationoptions)
2911
+ * See [Playwright's reference](https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions)
2861
2912
  *
2862
2913
  * @param {*} opts
2863
2914
  */
@@ -3287,7 +3338,7 @@ async function targetCreatedHandler(page) {
3287
3338
  }
3288
3339
  // if context element was in iframe - keep it
3289
3340
  // if (await this.context.ownerFrame()) return;
3290
- this.context = context;
3341
+ this.context = page;
3291
3342
  });
3292
3343
  });
3293
3344
  page.on('console', (msg) => {
@@ -723,7 +723,7 @@ class Protractor extends Helper {
723
723
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
724
724
  * ```
725
725
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
726
- * @param {string} value text value to fill.
726
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
727
727
  *
728
728
  */
729
729
  async fillField(field, value) {
@@ -231,7 +231,7 @@ class Puppeteer extends Helper {
231
231
  try {
232
232
  require('puppeteer');
233
233
  } catch (e) {
234
- return ['puppeteer@^3.0.1'];
234
+ return ['puppeteer'];
235
235
  }
236
236
  }
237
237
 
@@ -1593,7 +1593,7 @@ class Puppeteer extends Helper {
1593
1593
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
1594
1594
  * ```
1595
1595
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1596
- * @param {string} value text value to fill.
1596
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
1597
1597
  *
1598
1598
  * {{ react }}
1599
1599
  */
@@ -2647,7 +2647,7 @@ class Puppeteer extends Helper {
2647
2647
  if (!els || els.length === 0) {
2648
2648
  return false;
2649
2649
  }
2650
- return Array.prototype.filter.call(els, el => (el.value || '').indexOf(value) !== -1).length > 0;
2650
+ return Array.prototype.filter.call(els, el => (el.value.toString() || '').indexOf(value) !== -1).length > 0;
2651
2651
  };
2652
2652
  waiter = context.waitForFunction(valueFn, { timeout: waitTimeout }, locator.value, value);
2653
2653
  } else {
@@ -1,4 +1,5 @@
1
1
  const axios = require('axios').default;
2
+ const Secret = require('../secret');
2
3
 
3
4
  const Helper = require('../helper');
4
5
 
@@ -75,12 +76,18 @@ class REST extends Helper {
75
76
  * @param {*} request
76
77
  */
77
78
  async _executeRequest(request) {
79
+ const _debugRequest = { ...request };
78
80
  axios.defaults.timeout = request.timeout || this.options.timeout;
79
81
 
80
82
  if (this.headers && this.headers.auth) {
81
83
  request.auth = this.headers.auth;
82
84
  }
83
85
 
86
+ if (request.data instanceof Secret) {
87
+ _debugRequest.data = '*****';
88
+ request.data = typeof request.data === 'object' ? { ...request.data.toString() } : request.data.toString();
89
+ }
90
+
84
91
  if ((typeof request.data) === 'string') {
85
92
  if (!request.headers || !request.headers['Content-Type']) {
86
93
  request.headers = { ...request.headers, ...{ 'Content-Type': 'application/x-www-form-urlencoded' } };
@@ -91,7 +98,7 @@ class REST extends Helper {
91
98
  await this.config.onRequest(request);
92
99
  }
93
100
 
94
- this.debugSection('Request', JSON.stringify(request));
101
+ this.debugSection('Request', JSON.stringify(_debugRequest));
95
102
 
96
103
  let response;
97
104
  try {
@@ -149,6 +156,10 @@ class REST extends Helper {
149
156
  *
150
157
  * ```js
151
158
  * I.sendPostRequest('/api/users.json', { "email": "user@user.com" });
159
+ *
160
+ * // To mask the payload in logs
161
+ * I.sendPostRequest('/api/users.json', secret({ "email": "user@user.com" }));
162
+ *
152
163
  * ```
153
164
  *
154
165
  * @param {*} url
@@ -176,6 +187,10 @@ class REST extends Helper {
176
187
  *
177
188
  * ```js
178
189
  * I.sendPatchRequest('/api/users.json', { "email": "user@user.com" });
190
+ *
191
+ * // To mask the payload in logs
192
+ * I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" }));
193
+ *
179
194
  * ```
180
195
  *
181
196
  * @param {string} url
@@ -203,6 +218,10 @@ class REST extends Helper {
203
218
  *
204
219
  * ```js
205
220
  * I.sendPutRequest('/api/users.json', { "email": "user@user.com" });
221
+ *
222
+ * // To mask the payload in logs
223
+ * I.sendPutRequest('/api/users.json', secret({ "email": "user@user.com" }));
224
+ *
206
225
  * ```
207
226
  *
208
227
  * @param {string} url
@@ -440,7 +440,7 @@ class TestCafe extends Helper {
440
440
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
441
441
  * ```
442
442
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
443
- * @param {string} value text value to fill.
443
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
444
444
  *
445
445
  */
446
446
  async fillField(field, value) {
@@ -718,7 +718,7 @@ class WebDriver extends Helper {
718
718
  * @param {object} locator
719
719
  */
720
720
  async _smartWait(locator) {
721
- this.debugSection(`SmartWait (${this.options.smartWait}ms)`, `Locating ${locator} in ${this.options.smartWait}`);
721
+ this.debugSection(`SmartWait (${this.options.smartWait}ms)`, `Locating ${JSON.stringify(locator)} in ${this.options.smartWait}`);
722
722
  await this.defineTimeout({ implicit: this.options.smartWait });
723
723
  }
724
724
 
@@ -1076,7 +1076,7 @@ class WebDriver extends Helper {
1076
1076
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
1077
1077
  * ```
1078
1078
  * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1079
- * @param {string} value text value to fill.
1079
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
1080
1080
  *
1081
1081
  * {{ react }}
1082
1082
  *
@@ -1785,7 +1785,7 @@ class WebDriver extends Helper {
1785
1785
  */
1786
1786
  async grabBrowserLogs() {
1787
1787
  if (this.browser.isW3C) {
1788
- this.debug('Logs not awailable in W3C specification');
1788
+ this.debug('Logs not available in W3C specification');
1789
1789
  return;
1790
1790
  }
1791
1791
  return this.browser.getLogs('browser');
package/docs/changelog.md CHANGED
@@ -7,25 +7,90 @@ layout: Section
7
7
 
8
8
  # Releases
9
9
 
10
+ ## 3.0.5
11
+
12
+
13
+ Features:
14
+
15
+ * **[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](https://github.com/VikentyShevyrin)**
16
+ * Better support for Typescript `codecept.conf.ts` configuration files. See [#2750](https://github.com/codeceptjs/CodeceptJS/issues/2750) by **[elaichenkov](https://github.com/elaichenkov)**
17
+ * Propagate more events for custom parallel script. See [#2796](https://github.com/codeceptjs/CodeceptJS/issues/2796) by **[jccguimaraes](https://github.com/jccguimaraes)**
18
+ * [mocha-junit-reporter] Now supports attachments, see documentation for details. See [#2675](https://github.com/codeceptjs/CodeceptJS/issues/2675) by **[Shard](https://github.com/Shard)**
19
+ * CustomLocators interface for TypeScript to extend from LocatorOrString. See [#2798](https://github.com/codeceptjs/CodeceptJS/issues/2798) by **[danielrentz](https://github.com/danielrentz)**
20
+ * **[REST]** Mask sensitive data from log messages.
21
+ ```js
22
+ I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" }));
23
+ ```
24
+ See [#2786](https://github.com/codeceptjs/CodeceptJS/issues/2786) by **[PeterNgTr](https://github.com/PeterNgTr)**
25
+
26
+ Bug fixes:
27
+ * Fixed reporting of nested steps with PageObjects and BDD scenarios. See [#2800](https://github.com/codeceptjs/CodeceptJS/issues/2800) by **[davertmik](https://github.com/davertmik)**. Fixes [#2720](https://github.com/codeceptjs/CodeceptJS/issues/2720) [#2682](https://github.com/codeceptjs/CodeceptJS/issues/2682)
28
+ * Fixed issue with `codeceptjs shell` which was broken since 3.0.0. See [#2743](https://github.com/codeceptjs/CodeceptJS/issues/2743) by **[stedman](https://github.com/stedman)**
29
+ * **[Gherkin]** Fixed issue suppressed or hidden errors in tests. See [#2745](https://github.com/codeceptjs/CodeceptJS/issues/2745) by **[ktryniszewski-mdsol](https://github.com/ktryniszewski-mdsol)**
30
+ * **[Playwright]** fix grabCssPropertyFromAll serialization by using property names. See [#2757](https://github.com/codeceptjs/CodeceptJS/issues/2757) by **[elaichenkov](https://github.com/elaichenkov)**
31
+ * **[Allure]** fix report for multi sessions. See [#2771](https://github.com/codeceptjs/CodeceptJS/issues/2771) by **[cbayer97](https://github.com/cbayer97)**
32
+ * **[WebDriver]** Fix locator object debug log messages in smart wait. See 2748 by **[elaichenkov](https://github.com/elaichenkov)**
33
+
34
+ Documentation fixes:
35
+ * Fixed some broken examples. See [#2756](https://github.com/codeceptjs/CodeceptJS/issues/2756) by **[danielrentz](https://github.com/danielrentz)**
36
+ * Fixed Typescript typings. See [#2747](https://github.com/codeceptjs/CodeceptJS/issues/2747), [#2758](https://github.com/codeceptjs/CodeceptJS/issues/2758) and [#2769](https://github.com/codeceptjs/CodeceptJS/issues/2769) by **[elaichenkov](https://github.com/elaichenkov)**
37
+ * Added missing type for xFeature. See [#2754](https://github.com/codeceptjs/CodeceptJS/issues/2754) by **[PeterNgTr](https://github.com/PeterNgTr)**
38
+ * Fixed code example in Page Object documentation. See [#2793](https://github.com/codeceptjs/CodeceptJS/issues/2793) by **[mkrtchian](https://github.com/mkrtchian)**
39
+
40
+ Library updates:
41
+ * Updated Axios to 0.21.1. See by **[sseide](https://github.com/sseide)**
42
+ * Updated **[pollyjs](https://github.com/pollyjs)**/core **[pollyjs](https://github.com/pollyjs)**/adapter-puppeteer. See [#2760](https://github.com/codeceptjs/CodeceptJS/issues/2760) by **[Anikethana](https://github.com/Anikethana)**
43
+
44
+ ## 3.0.4
45
+
46
+ * **Hotfix** Fixed `init` script by adding `cross-spawn` package. By **[vipulgupta2048](https://github.com/vipulgupta2048)**
47
+ * Fixed handling error during initialization of `run-multiple`. See [#2730](https://github.com/codeceptjs/CodeceptJS/issues/2730) by **[wagoid](https://github.com/wagoid)**
48
+
49
+ ## 3.0.3
50
+
51
+ * **Playwright 1.7 support**
52
+ * **[Playwright]** Fixed handling null context in click. See [#2667](https://github.com/codeceptjs/CodeceptJS/issues/2667) by **[matthewjf](https://github.com/matthewjf)**
53
+ * **[Playwright]** Fixed `Cannot read property '$$' of null` when locating elements. See [#2713](https://github.com/codeceptjs/CodeceptJS/issues/2713) by **[matthewjf](https://github.com/matthewjf)**
54
+ * Command `npx codeceptjs init` improved
55
+ * auto-installing required packages
56
+ * better error messages
57
+ * fixed generating type definitions
58
+ * 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](https://github.com/codeceptjs/CodeceptJS/issues/2698) by **[Georgegriff](https://github.com/Georgegriff)**
59
+ * **[Puppeteer]** Fixed that `waitForFunction` was not working with number values. See [#2703](https://github.com/codeceptjs/CodeceptJS/issues/2703) by **[MumblesNZ](https://github.com/MumblesNZ)**
60
+ * Enabled autocompletion for custom helpers. [#2695](https://github.com/codeceptjs/CodeceptJS/issues/2695) by **[PeterNgTr](https://github.com/PeterNgTr)**
61
+ * Emit test.after on workers. Fix [#2693](https://github.com/codeceptjs/CodeceptJS/issues/2693) by **[jccguimaraes](https://github.com/jccguimaraes)**
62
+ * TypeScript: Allow .ts config files. See [#2708](https://github.com/codeceptjs/CodeceptJS/issues/2708) by **[elukoyanov](https://github.com/elukoyanov)**
63
+ * Fixed definitions generation errors by **[elukoyanov](https://github.com/elukoyanov)**. See [#2707](https://github.com/codeceptjs/CodeceptJS/issues/2707) and [#2718](https://github.com/codeceptjs/CodeceptJS/issues/2718)
64
+ * 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](https://github.com/codeceptjs/CodeceptJS/issues/2715) by **[elukoyanov](https://github.com/elukoyanov)**
65
+ * Emit hook.failed in workers. Fix [#2723](https://github.com/codeceptjs/CodeceptJS/issues/2723) by **[jccguimaraes](https://github.com/jccguimaraes)**
66
+ * [wdio plugin] Added `seleniumArgs` and `seleniumInstallArgs` config options for plugin. See [#2687](https://github.com/codeceptjs/CodeceptJS/issues/2687) by **[andrerleao](https://github.com/andrerleao)**
67
+ * [allure plugin] Added `addParameter` method in [#2717](https://github.com/codeceptjs/CodeceptJS/issues/2717) by **[jancorvus](https://github.com/jancorvus)**. Fixes [#2716](https://github.com/codeceptjs/CodeceptJS/issues/2716)
68
+ * Added mocha-based `--reporter-options` and `--reporter <name>` commands to `run-workers` command by in [#2691](https://github.com/codeceptjs/CodeceptJS/issues/2691) **[Ameterezu](https://github.com/Ameterezu)**
69
+ * Fixed infinite loop for junit reports. See [#2691](https://github.com/codeceptjs/CodeceptJS/issues/2691) **[Ameterezu](https://github.com/Ameterezu)**
70
+ * Added status, start/end time, and match line for BDD steps. See [#2678](https://github.com/codeceptjs/CodeceptJS/issues/2678) by **[ktryniszewski-mdsol](https://github.com/ktryniszewski-mdsol)**
71
+ * [stepByStepReport plugin] Fixed "helper.saveScreenshot is not a function". Fix [#2688](https://github.com/codeceptjs/CodeceptJS/issues/2688) by **[andrerleao](https://github.com/andrerleao)**
72
+
73
+
74
+
10
75
  ## 3.0.2
11
76
 
12
77
  * **[Playwright]** Fix connection close with remote browser. See [#2629](https://github.com/codeceptjs/CodeceptJS/issues/2629) by **[dipiash](https://github.com/dipiash)**
13
78
  * **[REST]** set maxUploadFileSize when performing api calls. See [#2611](https://github.com/codeceptjs/CodeceptJS/issues/2611) by **[PeterNgTr](https://github.com/PeterNgTr)**
14
- * Duplicate Scenario names (combined with Feature name) are now detected via a warning message.
79
+ * Duplicate Scenario names (combined with Feature name) are now detected via a warning message.
15
80
  Duplicate test names can cause `codeceptjs run-workers` to not function. See [#2656](https://github.com/codeceptjs/CodeceptJS/issues/2656) by **[Georgegriff](https://github.com/Georgegriff)**
16
81
  * Documentation fixes
17
82
 
18
83
  Bug Fixes:
19
84
  * --suites flag now should function correctly for `codeceptjs run-workers`. See [#2655](https://github.com/codeceptjs/CodeceptJS/issues/2655) by **[Georgegriff](https://github.com/Georgegriff)**
20
85
  * [autoLogin plugin] Login methods should now function as expected with `codeceptjs run-workers`. See [#2658](https://github.com/codeceptjs/CodeceptJS/issues/2658) by **[Georgegriff](https://github.com/Georgegriff)**, resolves [#2620](https://github.com/codeceptjs/CodeceptJS/issues/2620)
21
-
86
+
22
87
 
23
88
 
24
89
  ## 3.0.1
25
90
 
26
91
  ♨️ Hot fix:
27
92
  * Lock the mocha version to avoid the errors. See [#2624](https://github.com/codeceptjs/CodeceptJS/issues/2624) by PeterNgTr
28
-
93
+
29
94
  🐛 Bug Fix:
30
95
  * Fixed error handling in Scenario.js. See [#2607](https://github.com/codeceptjs/CodeceptJS/issues/2607) by haveac1gar
31
96
  * Changing type definition in order to allow the use of functions with any number of any arguments. See [#2616](https://github.com/codeceptjs/CodeceptJS/issues/2616) by akoltun
@@ -176,9 +241,9 @@ tryTo(() => I.click('Accept', '.cookies'));
176
241
  ## 2.6.11
177
242
 
178
243
  * **[Playwright]** Playwright 1.4 compatibility
179
- * **[Playwright]** Added `ignoreHTTPSErrors` config option (default: false). See [#2566](https://github.com/codeceptjs/CodeceptJS/issues/2566) by gurjeetbains
180
- * Added French translation by **[vimar](https://github.com/vimar)**
181
- * **[WebDriver]** Updated `dragSlider` to work in WebDriver W3C protocol. Fixes [#2557](https://github.com/codeceptjs/CodeceptJS/issues/2557) by suniljaiswal01
244
+ * **[Playwright]** Added `ignoreHTTPSErrors` config option (default: false). See [#2566](https://github.com/codeceptjs/CodeceptJS/issues/2566) by gurjeetbains
245
+ * Added French translation by **[vimar](https://github.com/vimar)**
246
+ * **[WebDriver]** Updated `dragSlider` to work in WebDriver W3C protocol. Fixes [#2557](https://github.com/codeceptjs/CodeceptJS/issues/2557) by suniljaiswal01
182
247
 
183
248
  ## 2.6.10
184
249
 
package/docs/data.md CHANGED
@@ -154,8 +154,8 @@ Scenario('check post page', async ({ I }) => {
154
154
  // cleanup created data
155
155
  After(({ I }) => {
156
156
  I.sendMutation(
157
- 'mutation deletePost($permalink: /ID!) { deletePost(permalink: /$id) }',
158
- { permalink: /postData.id},
157
+ 'mutation deletePost($id: ID!) { deletePost(id: $id) }',
158
+ { id: postData.id},
159
159
  );
160
160
  });
161
161
  ```
@@ -196,7 +196,7 @@ The way for setting data for a test is as simple as writing:
196
196
  ```js
197
197
  // inside async function
198
198
  let post = await I.have('post');
199
- I.haveMultiple('comment', 5, { postpermalink: /post.id});
199
+ I.haveMultiple('comment', 5, { postId: post.id});
200
200
  ```
201
201
 
202
202
  After completing the preparations under 'Data Generation with Factories', create a factory module which will export a factory.
@@ -248,7 +248,7 @@ This way for setting data for a test is as simple as writing:
248
248
  ```js
249
249
  // inside async function
250
250
  let post = await I.mutateData('createPost');
251
- I.mutateMultiple('createComment', 5, { postpermalink: /post.id});
251
+ I.mutateMultiple('createComment', 5, { postId: post.id});
252
252
  ```
253
253
 
254
254
 
@@ -288,7 +288,7 @@ GraphQLDataFactory: {
288
288
  query: 'mutation createUser($input: UserInput!) { createUser(input: $input) { id name }}',
289
289
  factory: './factories/users',
290
290
  revert: (data) => ({
291
- query: 'mutation deleteUser($permalink: /ID!) { deleteUser(permalink: /$id) }',
291
+ query: 'mutation deleteUser($id: ID!) { deleteUser(id: $id) }',
292
292
  variables: { id : data.id},
293
293
  }),
294
294
  },
package/docs/detox.md CHANGED
@@ -179,7 +179,7 @@ If element differs on on iOS and Android you can use **cross platform locators**
179
179
  ```js
180
180
  // locate element by text on Android
181
181
  // locate element by accessibility id on iOS
182
- I.click({ android: /'Start', ios: '~start' });
182
+ I.click({ android: 'Start', ios: '~start' });
183
183
  ```
184
184
 
185
185
  When application behavior differs on Android and iOS use platform-specific actions:
@@ -207,7 +207,7 @@ Scenario('save in application', ({ I }) => {
207
207
  I.fillField('#text', 'a new text');
208
208
  I.see('a new text', '#textValue');
209
209
  I.dontSeeElement('#createdAndVisibleText');
210
- I.click({ ios: '#GoButton', android: /'Button' });
210
+ I.click({ ios: '#GoButton', android: 'Button' });
211
211
  I.waitForElement('#createdAndVisibleText', 20);
212
212
  I.seeElement('#createdAndVisibleText');
213
213
  I.runOnAndroid(() => {