codeceptjs 3.3.4 → 3.3.5-beta.1

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 (61) hide show
  1. package/docs/bdd.md +12 -0
  2. package/docs/build/Playwright.js +42 -36
  3. package/docs/build/Puppeteer.js +54 -43
  4. package/docs/build/REST.js +18 -8
  5. package/docs/build/WebDriver.js +34 -25
  6. package/docs/changelog.md +0 -38
  7. package/docs/community-helpers.md +1 -0
  8. package/docs/configuration.md +21 -18
  9. package/docs/helpers/Appium.md +0 -723
  10. package/docs/helpers/Playwright.md +269 -263
  11. package/docs/helpers/Puppeteer.md +230 -222
  12. package/docs/helpers/REST.md +20 -7
  13. package/docs/helpers/WebDriver.md +265 -259
  14. package/docs/reports.md +11 -0
  15. package/docs/wiki/.git/FETCH_HEAD +1 -0
  16. package/docs/wiki/.git/HEAD +1 -0
  17. package/docs/wiki/.git/ORIG_HEAD +1 -0
  18. package/docs/wiki/.git/config +11 -0
  19. package/docs/wiki/.git/description +1 -0
  20. package/docs/wiki/.git/hooks/applypatch-msg.sample +15 -0
  21. package/docs/wiki/.git/hooks/commit-msg.sample +24 -0
  22. package/docs/wiki/.git/hooks/fsmonitor-watchman.sample +173 -0
  23. package/docs/wiki/.git/hooks/post-update.sample +8 -0
  24. package/docs/wiki/.git/hooks/pre-applypatch.sample +14 -0
  25. package/docs/wiki/.git/hooks/pre-commit.sample +49 -0
  26. package/docs/wiki/.git/hooks/pre-merge-commit.sample +13 -0
  27. package/docs/wiki/.git/hooks/pre-push.sample +53 -0
  28. package/docs/wiki/.git/hooks/pre-rebase.sample +169 -0
  29. package/docs/wiki/.git/hooks/pre-receive.sample +24 -0
  30. package/docs/wiki/.git/hooks/prepare-commit-msg.sample +42 -0
  31. package/docs/wiki/.git/hooks/push-to-checkout.sample +78 -0
  32. package/docs/wiki/.git/hooks/update.sample +128 -0
  33. package/docs/wiki/.git/index +0 -0
  34. package/docs/wiki/.git/info/exclude +6 -0
  35. package/docs/wiki/.git/logs/HEAD +1 -0
  36. package/docs/wiki/.git/logs/refs/heads/master +1 -0
  37. package/docs/wiki/.git/logs/refs/remotes/origin/HEAD +1 -0
  38. package/docs/wiki/.git/objects/pack/pack-5938044f9d30daf1c195fda4dec1d54850933935.idx +0 -0
  39. package/docs/wiki/.git/objects/pack/pack-5938044f9d30daf1c195fda4dec1d54850933935.pack +0 -0
  40. package/docs/wiki/.git/packed-refs +2 -0
  41. package/docs/wiki/.git/refs/heads/master +1 -0
  42. package/docs/wiki/.git/refs/remotes/origin/HEAD +1 -0
  43. package/docs/wiki/Community-Helpers-&-Plugins.md +7 -3
  44. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +29 -0
  45. package/docs/wiki/Examples.md +39 -48
  46. package/docs/wiki/Release-Process.md +8 -8
  47. package/docs/wiki/Tests.md +62 -60
  48. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +2 -2
  49. package/lib/command/generate.js +3 -0
  50. package/lib/command/init.js +83 -24
  51. package/lib/helper/Playwright.js +42 -36
  52. package/lib/helper/Puppeteer.js +54 -43
  53. package/lib/helper/REST.js +18 -8
  54. package/lib/helper/WebDriver.js +34 -25
  55. package/lib/interfaces/gherkin.js +1 -1
  56. package/lib/secret.js +1 -1
  57. package/lib/step.js +21 -9
  58. package/lib/utils.js +1 -6
  59. package/package.json +3 -3
  60. package/typings/index.d.ts +158 -0
  61. package/typings/types.d.ts +340 -94
package/docs/bdd.md CHANGED
@@ -356,6 +356,18 @@ In case scenarios represent the same logic but differ on data, we can use *Scena
356
356
  | 50 | 45 |
357
357
  ```
358
358
 
359
+ It might be the case that the same column value needs to be utilized multiple times in the same step, that also can be possible with scenario outline.
360
+
361
+ ```gherkin
362
+ Scenario Outline: check parameter substitution
363
+ Given I have a defined step
364
+ When I see "<text>" text and "<text>" is not "xyz"
365
+ Examples:
366
+ | text |
367
+ | Google |
368
+
369
+ ```
370
+
359
371
  ### Long Strings
360
372
 
361
373
  Text values inside a scenarios can be set inside a `"""` block:
@@ -44,6 +44,46 @@ const {
44
44
  } = require('./extras/PlaywrightRestartOpts');
45
45
  const { createValueEngine, createDisabledEngine } = require('./extras/PlaywrightPropEngine');
46
46
 
47
+ /**
48
+ * ## Configuration
49
+ *
50
+ * This helper should be configured in codecept.conf.js
51
+ *
52
+ * @typedef PlaywrightConfig
53
+ * @type {object}
54
+ * @prop {string} url - base url of website to be tested
55
+ * @prop {string} browser - a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
56
+ * @prop {boolean} [show=false] - show browser window.
57
+ * @prop {string|boolean} [restart=false] - restart strategy between tests. Possible values:
58
+ * * 'context' or **false** - restarts [browser context](https://playwright.dev/docs/api/class-browsercontext) but keeps running browser. Recommended by Playwright team to keep tests isolated.
59
+ * * 'browser' or **true** - closes browser and opens it again between tests.
60
+ * * 'session' or 'keep' - keeps browser context and session, but cleans up cookies and localStorage between tests. The fastest option when running tests in windowed mode. Works with `keepCookies` and `keepBrowserState` options. This behavior was default before CodeceptJS 3.1
61
+ * @prop {number} [timeout=1000] - - [timeout](https://playwright.dev/docs/api/class-page#page-set-default-timeout) in ms of all Playwright actions .
62
+ * @prop {boolean} [disableScreenshots=false] - don't save screenshot on failure.
63
+ * @prop {any} [emulate] - browser in device emulation mode.
64
+ * @prop {boolean} [video=false] - enables video recording for failed tests; videos are saved into `output/videos` folder
65
+ * @prop {boolean} [trace=false] - record [tracing information](https://playwright.dev/docs/trace-viewer) with screenshots and snapshots.
66
+ * @prop {boolean} [fullPageScreenshots=false] - make full page screenshots on failure.
67
+ * @prop {boolean} [uniqueScreenshotNames=false] - option to prevent screenshot override if you have scenarios with the same name in different suites.
68
+ * @prop {boolean} [keepBrowserState=false] - keep browser state between tests when `restart` is set to 'session'.
69
+ * @prop {boolean} [keepCookies=false] - keep cookies between tests when `restart` is set to 'session'.
70
+ * @prop {number} [waitForAction] - how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
71
+ * @prop {number} [waitForNavigation] - When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle`. Choose one of those options is possible. See [Playwright API](https://github.com/microsoft/playwright/blob/main/docs/api.md#pagewaitfornavigationoptions).
72
+ * @prop {number} [pressKeyDelay=10] - Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
73
+ * @prop {number} [getPageTimeout] - config option to set maximum navigation time in milliseconds.
74
+ * @prop {number} [waitForTimeout] - default wait* timeout in ms. Default: 1000.
75
+ * @prop {object} [basicAuth] - the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
76
+ * @prop {string} [windowSize] - default window size. Set a dimension like `640x480`.
77
+ * @prop {string} [colorScheme] - default color scheme. Possible values: `dark` | `light` | `no-preference`.
78
+ * @prop {string} [userAgent] - user-agent string.
79
+ * @prop {string} [locale] - locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
80
+ * @prop {boolean} [manualStart] - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
81
+ * @prop {object} [chromium] - pass additional chromium options
82
+ * @prop {object} [electron] - (pass additional electron options
83
+ * @prop {any} [channel] - (While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge](https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge).
84
+ */
85
+ const config = {};
86
+
47
87
  /**
48
88
  * Uses [Playwright](https://github.com/microsoft/playwright) library to run tests inside:
49
89
  *
@@ -65,46 +105,14 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
65
105
  *
66
106
  * Using playwright-core package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
67
107
  *
68
- * ## Configuration
69
108
  *
70
- * This helper should be configured in codecept.json or codecept.conf.js
71
- *
72
- * * `url`: base url of website to be tested
73
- * * `browser`: a browser to test on, either: `chromium`, `firefox`, `webkit`, `electron`. Default: chromium.
74
- * * `show`: (optional, default: false) - show browser window.
75
- * * `restart`: (optional, default: false) - restart strategy between tests. Possible values:
76
- * * 'context' or **false** - restarts [browser context](https://playwright.dev/docs/api/class-browsercontext) but keeps running browser. Recommended by Playwright team to keep tests isolated.
77
- * * 'browser' or **true** - closes browser and opens it again between tests.
78
- * * 'session' or 'keep' - keeps browser context and session, but cleans up cookies and localStorage between tests. The fastest option when running tests in windowed mode. Works with `keepCookies` and `keepBrowserState` options. This behavior was default before CodeceptJS 3.1
79
- * * `timeout`: (optional, default: 1000) - [timeout](https://playwright.dev/docs/api/class-page#page-set-default-timeout) in ms of all Playwright actions .
80
- * * `disableScreenshots`: (optional, default: false) - don't save screenshot on failure.
81
- * * `emulate`: (optional, default: {}) launch browser in device emulation mode.
82
- * * `video`: (optional, default: false) enables video recording for failed tests; videos are saved into `output/videos` folder
83
- * * `trace`: (optional, default: false) record [tracing information](https://playwright.dev/docs/trace-viewer) with screenshots and snapshots.
84
- * * `fullPageScreenshots` (optional, default: false) - make full page screenshots on failure.
85
- * * `uniqueScreenshotNames`: (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suites.
86
- * * `keepBrowserState`: (optional, default: false) - keep browser state between tests when `restart` is set to 'session'.
87
- * * `keepCookies`: (optional, default: false) - keep cookies between tests when `restart` is set to 'session'.
88
- * * `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
89
- * * `waitForNavigation`: (optional, default: 'load'). When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle`. Choose one of those options is possible. See [Playwright API](https://github.com/microsoft/playwright/blob/main/docs/api.md#pagewaitfornavigationoptions).
90
- * * `pressKeyDelay`: (optional, default: '10'). Delay between key presses in ms. Used when calling Playwrights page.type(...) in fillField/appendField
91
- * * `getPageTimeout` (optional, default: '0') config option to set maximum navigation time in milliseconds.
92
- * * `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
93
- * * `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
94
- * * `windowSize`: (optional) default window size. Set a dimension like `640x480`.
95
- * * `colorScheme`: (optional) default color scheme. Possible values: `dark` | `light` | `no-preference`.
96
- * * `userAgent`: (optional) user-agent string.
97
- * * `locale`: (optional) locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
98
- * * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
99
- * * `chromium`: (optional) pass additional chromium options
100
- * * `electron`: (optional) pass additional electron options
101
- * * `channel`: (optional) While Playwright can operate against the stock Google Chrome and Microsoft Edge browsers available on the machine. In particular, current Playwright version will support Stable and Beta channels of these browsers. See [Google Chrome & Microsoft Edge](https://playwright.dev/docs/browsers/#google-chrome--microsoft-edge).
109
+ * <!-- configuration -->
102
110
  *
103
111
  * #### Video Recording Customization
104
112
  *
105
113
  * By default, video is saved to `output/video` dir. You can customize this path by passing `dir` option to `recordVideo` option.
106
114
  *
107
- * * `video`: enables video recording for failed tests; videos are saved into `output/videos` folder
115
+ * `video`: enables video recording for failed tests; videos are saved into `output/videos` folder
108
116
  * * `keepVideoForPassedTests`: - save videos for passed tests
109
117
  * * `recordVideo`: [additional options for videos customization](https://playwright.dev/docs/next/api/class-browser#browser-new-context)
110
118
  *
@@ -257,8 +265,6 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
257
265
  * const { browserContext } = this.helpers.Playwright;
258
266
  * await browserContext.cookies(); // get current browser context
259
267
  * ```
260
- *
261
- * ## Methods
262
268
  */
263
269
  class Playwright extends Helper {
264
270
  constructor(config) {
@@ -39,6 +39,35 @@ let perfTiming;
39
39
  const popupStore = new Popup();
40
40
  const consoleLogStore = new Console();
41
41
 
42
+ /**
43
+ * ## Configuration
44
+ *
45
+ * This helper should be configured in codecept.conf.js
46
+ *
47
+ * @typedef PuppeteerConfig
48
+ * @type {object}
49
+ * @prop {string} url - base url of website to be tested
50
+ * @prop {object} [basicAuth] (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
51
+ * @prop {boolean} [show] - show Google Chrome window for debug.
52
+ * @prop {boolean} [restart=true] - restart browser between tests.
53
+ * @prop {boolean} [disableScreenshots=false] - don't save screenshot on failure.
54
+ * @prop {boolean} [fullPageScreenshots=false] - make full page screenshots on failure.
55
+ * @prop {boolean} [uniqueScreenshotNames=false] - option to prevent screenshot override if you have scenarios with the same name in different suites.
56
+ * @prop {boolean} [keepBrowserState=false] - keep browser state between tests when `restart` is set to false.
57
+ * @prop {boolean} [keepCookies=false] - keep cookies between tests when `restart` is set to false.
58
+ * @prop {number} [waitForAction=100] - how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
59
+ * @prop {string} [waitForNavigation=load] - when to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. See [Puppeteer API](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions). Array values are accepted as well.
60
+ * @prop {number} [pressKeyDelay=10] - delay between key presses in ms. Used when calling Puppeteers page.type(...) in fillField/appendField
61
+ * @prop {number} [getPageTimeout=30000] - config option to set maximum navigation time in milliseconds. If the timeout is set to 0, then timeout will be disabled.
62
+ * @prop {number} [waitForTimeout=1000] - default wait* timeout in ms.
63
+ * @prop {string} [windowSize] - default window size. Set a dimension in format WIDTHxHEIGHT like `640x480`.
64
+ * @prop {string} [userAgent] - user-agent string.
65
+ * @prop {boolean} [manualStart=false] - do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
66
+ * @prop {string} [browser=chrome] - can be changed to `firefox` when using [puppeteer-firefox](https://codecept.io/helpers/Puppeteer-firefox).
67
+ * @prop {object} [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
68
+ */
69
+ const config = {};
70
+
42
71
  /**
43
72
  * Uses [Google Chrome's Puppeteer](https://github.com/GoogleChrome/puppeteer) library to run tests inside headless Chrome.
44
73
  * Browser control is executed via DevTools Protocol (instead of Selenium).
@@ -56,30 +85,7 @@ const consoleLogStore = new Console();
56
85
  *
57
86
  * > Experimental Firefox support [can be activated](https://codecept.io/helpers/Puppeteer-firefox).
58
87
  *
59
- * ## Configuration
60
- *
61
- * This helper should be configured in codecept.json or codecept.conf.js
62
- *
63
- * * `url`: base url of website to be tested
64
- * * `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
65
- * * `show`: (optional, default: false) - show Google Chrome window for debug.
66
- * * `restart`: (optional, default: true) - restart browser between tests.
67
- * * `disableScreenshots`: (optional, default: false) - don't save screenshot on failure.
68
- * * `fullPageScreenshots` (optional, default: false) - make full page screenshots on failure.
69
- * * `uniqueScreenshotNames`: (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suites.
70
- * * `keepBrowserState`: (optional, default: false) - keep browser state between tests when `restart` is set to false.
71
- * * `keepCookies`: (optional, default: false) - keep cookies between tests when `restart` is set to false.
72
- * * `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 100.
73
- * * `waitForNavigation`: (optional, default: 'load'). When to consider navigation succeeded. Possible options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. See [Puppeteer API](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions). Array values are accepted as well.
74
- * * `pressKeyDelay`: (optional, default: '10'). Delay between key presses in ms. Used when calling Puppeteers page.type(...) in fillField/appendField
75
- * * `getPageTimeout` (optional, default: '30000') config option to set maximum navigation time in milliseconds. If the timeout is set to 0, then timeout will be disabled.
76
- * * `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
77
- * * `windowSize`: (optional) default window size. Set a dimension like `640x480`.
78
- * * `userAgent`: (optional) user-agent string.
79
- * * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
80
- * * `browser`: (optional, default: chrome) - can be changed to `firefox` when using [puppeteer-firefox](https://codecept.io/helpers/Puppeteer-firefox).
81
- * * `chrome`: (optional) pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
82
- *
88
+ * <!-- configuration -->
83
89
  *
84
90
  * #### Example #1: Wait for 0 network connections.
85
91
  *
@@ -192,7 +198,6 @@ class Puppeteer extends Helper {
192
198
  super(config);
193
199
 
194
200
  puppeteer = requireWithFallback('puppeteer', 'puppeteer-core');
195
-
196
201
  // set defaults
197
202
  this.isRemoteBrowser = false;
198
203
  this.isRunning = false;
@@ -372,22 +377,22 @@ class Puppeteer extends Helper {
372
377
  }
373
378
 
374
379
  /**
375
- * Use Puppeteer API inside a test.
376
- *
377
- * First argument is a description of an action.
378
- * Second argument is async function that gets this helper as parameter.
379
- *
380
- * { [`page`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-page), [`browser`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-browser) } from Puppeteer API are available.
381
- *
382
- * ```js
383
- * I.usePuppeteerTo('emulate offline mode', async ({ page }) {
384
- * await page.setOfflineMode(true);
385
- * });
386
- * ```
387
- *
388
- * @param {string} description used to show in logs.
389
- * @param {function} fn async function that is executed with Puppeteer as argument
390
- */
380
+ * Use Puppeteer API inside a test.
381
+ *
382
+ * First argument is a description of an action.
383
+ * Second argument is async function that gets this helper as parameter.
384
+ *
385
+ * { [`page`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-page), [`browser`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-browser) } from Puppeteer API are available.
386
+ *
387
+ * ```js
388
+ * I.usePuppeteerTo('emulate offline mode', async ({ page }) {
389
+ * await page.setOfflineMode(true);
390
+ * });
391
+ * ```
392
+ *
393
+ * @param {string} description used to show in logs.
394
+ * @param {function} fn async function that is executed with Puppeteer as argument
395
+ */
391
396
  usePuppeteerTo(description, fn) {
392
397
  return this._useTo(...arguments);
393
398
  }
@@ -816,7 +821,8 @@ class Puppeteer extends Helper {
816
821
  if (locator) {
817
822
  const els = await this._locate(locator);
818
823
  assertElementExists(els, locator, 'Element');
819
- await els[0]._scrollIntoViewIfNeeded();
824
+ const el = els[0];
825
+ await el.evaluate((el) => el.scrollIntoView());
820
826
  const elementCoordinates = await getClickablePoint(els[0]);
821
827
  await this.executeScript((x, y) => window.scrollBy(x, y), elementCoordinates.x + offsetX, elementCoordinates.y + offsetY);
822
828
  } else {
@@ -1268,7 +1274,12 @@ class Puppeteer extends Helper {
1268
1274
  fs.mkdirSync(downloadPath, '0777');
1269
1275
  }
1270
1276
  fsExtra.emptyDirSync(downloadPath);
1271
- return this.page._client.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath });
1277
+
1278
+ try {
1279
+ return this.page._client.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath });
1280
+ } catch (e) {
1281
+ return this.page._client().send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath });
1282
+ }
1272
1283
  }
1273
1284
 
1274
1285
  /**
@@ -4,18 +4,26 @@ const Secret = require('../secret');
4
4
  const Helper = require('../helper');
5
5
  const { beautify } = require('../utils');
6
6
 
7
+ /**
8
+ * ## Configuration
9
+ *
10
+ * @typedef RESTConfig
11
+ * @type {object}
12
+ * @prop {string} endpoint - API base URL
13
+ * @prop {boolean} [prettyPrintJson=false] - pretty print json for response/request on console logs
14
+ * @prop {number} [timeout=1000] - timeout for requests in milliseconds. 10000ms by default
15
+ * @prop {object} [defaultHeaders] - a list of default headers
16
+ * @prop {function} [onRequest] - a async function which can update request object.
17
+ * @prop {function} [onResponse] - a async function which can update response object.
18
+ * @prop {number} [maxUploadFileSize] - set the max content file size in MB when performing api calls.
19
+ */
20
+ const config = {};
21
+
7
22
  /**
8
23
  * REST helper allows to send additional requests to the REST API during acceptance tests.
9
24
  * [Axios](https://github.com/axios/axios) library is used to perform requests.
10
25
  *
11
- * ## Configuration
12
- *
13
- * * endpoint: API base URL
14
- * * prettyPrintJson: pretty print json for response/request on console logs
15
- * * timeout: timeout for requests in milliseconds. 10000ms by default
16
- * * defaultHeaders: a list of default headers
17
- * * onRequest: a async function which can update request object.
18
- * * maxUploadFileSize: set the max content file size in MB when performing api calls.
26
+ * <!-- configuration -->
19
27
  *
20
28
  * ## Example
21
29
  *
@@ -53,6 +61,8 @@ class REST extends Helper {
53
61
  defaultHeaders: {},
54
62
  endpoint: '',
55
63
  prettyPrintJson: false,
64
+ onRequest: null,
65
+ onResponse: null,
56
66
  };
57
67
 
58
68
  if (this.options.maxContentLength) {
@@ -32,37 +32,43 @@ const SHADOW = 'shadow';
32
32
  const webRoot = 'body';
33
33
 
34
34
  let version;
35
+
36
+ /**
37
+ * ## Configuration
38
+ *
39
+ * This helper should be configured in codecept.conf.js
40
+ *
41
+ * @typedef WebDriverConfig
42
+ * @type {object}
43
+ * @prop {string} url - base url of website to be tested.
44
+ * @prop {string} browser browser in which to perform testing.
45
+ * @prop {string} [basicAuth] - (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
46
+ * @prop {string} [host=localhost] - WebDriver host to connect.
47
+ * @prop {string} [port=4444] - WebDriver port to connect.
48
+ * @prop {string} [protocol=http] - protocol for WebDriver server.
49
+ * @prop {string} [path=/wd/hub] - path to WebDriver server,
50
+ * @prop {boolean} [restart=true] - restart browser between tests.
51
+ * @prop {boolean} [smartWait=false] - **enables [SmartWait](http://codecept.io/acceptance/#smartwait)**; wait for additional milliseconds for element to appear. Enable for 5 secs: "smartWait": 5000.
52
+ * @prop {boolean} [disableScreenshots=false] - don't save screenshots on failure.
53
+ * @prop {boolean} [fullPageScreenshots=false] (optional - make full page screenshots on failure.
54
+ * @prop {boolean} [uniqueScreenshotNames=false] - option to prevent screenshot override if you have scenarios with the same name in different suites.
55
+ * @prop {boolean} [keepBrowserState=false] - keep browser state between tests when `restart` is set to false.
56
+ * @prop {boolean} [keepCookies=false] - keep cookies between tests when `restart` set to false.
57
+ * @prop {string} [windowSize=window] default window size. Set to `maximize` or a dimension in the format `640x480`.
58
+ * @prop {number} [waitForTimeout=1000] sets default wait time in *ms* for all `wait*` functions.
59
+ * @prop {object} [desiredCapabilities] Selenium's [desired capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities).
60
+ * @prop {boolean} [manualStart=false] - do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriver"]._startBrowser()`.
61
+ * @prop {object} [timeouts] [WebDriver timeouts](http://webdriver.io/docs/timeouts.html) defined as hash.
62
+ */
63
+ const config = {};
64
+
35
65
  /**
36
66
  * WebDriver helper which wraps [webdriverio](http://webdriver.io/) library to
37
67
  * manipulate browser using Selenium WebDriver or PhantomJS.
38
68
  *
39
69
  * WebDriver requires Selenium Server and ChromeDriver/GeckoDriver to be installed. Those tools can be easily installed via NPM. Please check [Testing with WebDriver](https://codecept.io/webdriver/#testing-with-webdriver) for more details.
40
70
  *
41
- * ### Configuration
42
- *
43
- * This helper should be configured in codecept.json or codecept.conf.js
44
- *
45
- * * `url`: base url of website to be tested.
46
- * * `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
47
- * * `browser`: browser in which to perform testing.
48
- * * `host`: (optional, default: localhost) - WebDriver host to connect.
49
- * * `port`: (optional, default: 4444) - WebDriver port to connect.
50
- * * `protocol`: (optional, default: http) - protocol for WebDriver server.
51
- * * `path`: (optional, default: /wd/hub) - path to WebDriver server,
52
- * * `restart`: (optional, default: true) - restart browser between tests.
53
- * * `smartWait`: (optional) **enables [SmartWait](http://codecept.io/acceptance/#smartwait)**; wait for additional milliseconds for element to appear. Enable for 5 secs: "smartWait": 5000.
54
- * * `disableScreenshots`: (optional, default: false) - don't save screenshots on failure.
55
- * * `fullPageScreenshots` (optional, default: false) - make full page screenshots on failure.
56
- * * `uniqueScreenshotNames`: (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suites.
57
- * * `keepBrowserState`: (optional, default: false) - keep browser state between tests when `restart` is set to false.
58
- * * `keepCookies`: (optional, default: false) - keep cookies between tests when `restart` set to false.
59
- * * `windowSize`: (optional) default window size. Set to `maximize` or a dimension in the format `640x480`.
60
- * * `waitForTimeout`: (optional, default: 1000) sets default wait time in *ms* for all `wait*` functions.
61
- * * `desiredCapabilities`: Selenium's [desired
62
- * capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities).
63
- * * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper
64
- * with `this.helpers["WebDriver"]._startBrowser()`.
65
- * * `timeouts`: [WebDriver timeouts](http://webdriver.io/docs/timeouts.html) defined as hash.
71
+ * <!-- configuration -->
66
72
  *
67
73
  * Example:
68
74
  *
@@ -567,6 +573,9 @@ class WebDriver extends Helper {
567
573
  });
568
574
  }
569
575
 
576
+ if (this.browser.capabilities && this.browser.capabilities.platformName) {
577
+ this.browser.capabilities.platformName = this.browser.capabilities.platformName.toLowerCase();
578
+ }
570
579
  return this.browser;
571
580
  }
572
581
 
package/docs/changelog.md CHANGED
@@ -7,44 +7,6 @@ layout: Section
7
7
 
8
8
  # Releases
9
9
 
10
- ## 3.3.4
11
-
12
- * Added support for masking fields in objects via `secret` function:
13
-
14
- ```js
15
- I.sendPostRequest('/auth', secret({ name: 'jon', password: '123456' }, 'password'));
16
- ```
17
- * Added [a guide about using of `secret`](/secrets) function
18
- * **[Appium]** Use `touchClick` when interacting with elements in iOS. See [#3317](https://github.com/codeceptjs/CodeceptJS/issues/3317) by **[mikk150](https://github.com/mikk150)**
19
- * **[Playwright]** Added `cdpConnection` option to connect over CDP. See [#3309](https://github.com/codeceptjs/CodeceptJS/issues/3309) by **[Hmihaly](https://github.com/Hmihaly)**
20
- * [customLocator plugin] Allowed to specify multiple attributes for custom locator. Thanks to **[aruiz-caritsqa](https://github.com/aruiz-caritsqa)**
21
-
22
- ```js
23
- plugins: {
24
- customLocator: {
25
- enabled: true,
26
- prefix: '$',
27
- attribute: ['data-qa', 'data-test'],
28
- }
29
- }
30
- ```
31
- * [retryTo plugin] Fixed [#3147](https://github.com/codeceptjs/CodeceptJS/issues/3147) using `pollInterval` option. See [#3351](https://github.com/codeceptjs/CodeceptJS/issues/3351) by **[cyonkee](https://github.com/cyonkee)**
32
- * **[Playwright]** Fixed grabbing of browser console messages and window resize in new tab. Thanks to **[mirao](https://github.com/mirao)**
33
- * **[REST]** Added `prettyPrintJson` option to print JSON in nice way by **[PeterNgTr](https://github.com/PeterNgTr)**
34
- * **[JSONResponse]** Updated response validation to iterate over array items if response is array. Thanks to **[PeterNgTr](https://github.com/PeterNgTr)**
35
-
36
- ```js
37
- // response.data == [
38
- // { user: { name: 'jon', email: 'jon@doe.com' } },
39
- // { user: { name: 'matt', email: 'matt@doe.com' } },
40
- //]
41
-
42
- I.seeResponseContainsKeys(['user']);
43
- I.seeResponseContainsJson({ user: { email: 'jon@doe.com' } });
44
- I.seeResponseContainsJson({ user: { email: 'matt@doe.com' } });
45
- I.dontSeeResponseContainsJson({ user: 2 });
46
- ```
47
-
48
10
  ## 3.3.3
49
11
 
50
12
  * Fixed `DataCloneError: () => could not be cloned` when running data tests in run-workers
@@ -37,6 +37,7 @@ Please **add your own** by editing this page.
37
37
  * [codeceptjs-rphelper](https://github.com/reportportal/agent-js-codecept) is a CodeceptJS helper which can publish tests results on ReportPortal after execution.
38
38
  * [codeceptjs-xray-helper](https://www.npmjs.com/package/codeceptjs-xray-helper) is a CodeceptJS helper which can publish tests results on [XRAY](https://confluence.xpand-it.com/display/XRAYCLOUD/Import+Execution+Results+-+REST).
39
39
  * [codeceptjs-slack-reporter](https://www.npmjs.com/package/codeceptjs-slack-reporter) Get a Slack notification when one or more scenarios fail.
40
+ * [codeceptjs-tesults](https://www.npmjs.com/package/codeceptjs-tesults) Report test results data from CodeceptJS to Tesults with this plugin.
40
41
 
41
42
  ## Page Object Code Generator
42
43
  * [codeceptjs-CodeGenerator](https://github.com/senthillkumar/CodeCeptJS-PageObject) is a CodeceptJS custom wrapper which can create page class with action methods from the page object file(JSON) and project setup(Folder Structure).
@@ -9,24 +9,27 @@ CodeceptJS configuration is set in `codecept.conf.js` file.
9
9
 
10
10
  After running `codeceptjs init` it should be saved in test root.
11
11
 
12
- Here is an overview of available options with their defaults:
13
-
14
- * **tests**: `"./*_test.js"` - pattern to locate tests. Allows to enter [glob pattern](https://github.com/isaacs/node-glob), Can either be a pattern to locate tests or an array of patterns to locate tests / test file names.
15
- * **grep**: - pattern to filter tests by name
16
- * **include**: `{}` - actors and page objects to be registered in DI container and included in tests. Accepts objects and module `require` paths
17
- * **timeout**: `10000` - default tests timeout
18
- * **output**: `"./output"` - where to store failure screenshots, etc
19
- * **helpers**: `{}` - list of enabled helpers
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
- * **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](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
- * **require**: `[]` - array of module names to be required before codecept starts. See [Require](#require)
12
+ | Name | Type | Description |
13
+ | :------ | :------ | :------ |
14
+ | `bootstrap` | `Function` \| `boolean` \| `string` | Execute JS code before tests are run. https://codecept.io/bootstrap/ Can be either JS module file or async function: ```js bootstrap: async () => server.launch(), ``` or ```js bootstrap: 'bootstrap.js', ``` |
15
+ | `bootstrapAll` | `Function` \| `boolean` \| `string` | Execute JS code before launching tests in parallel mode. https://codecept.io/bootstrap/#bootstrapall-teardownall |
16
+ | `gherkin?` | { `features`: `string` \| `string`[] ; `steps`: `string`[] } | Enable BDD features. https://codecept.io/bdd/#configuration Sample configuration: ```js gherkin: { features: "./features/*.feature", steps: ["./step_definitions/steps.js"] } ``` |
17
+ | `gherkin.features` | `string` \| `string`[] | load feature files by pattern. Multiple patterns can be specified as array |
18
+ | `gherkin.steps` | `string`[] | load step definitions from JS files |
19
+ | `grep` | `string` | Pattern to filter tests by name |
20
+ | `helpers?` | { `[key: string]`: `any`; } | Enabled and configured helpers ```js helpers: { Playwright: { url: 'https://mysite.com', browser: 'firefox' } } ``` |
21
+ | `include?` | `any` | Include page objects to access them via dependency injection ```js I: "./custom_steps.js", loginPage: "./pages/Login.js", User: "./pages/User.js", ``` Configured modules can be injected by name in a Scenario: ```js Scenario('test', { I, loginPage, User }) ``` |
22
+ | `mocha?` | `any` | [Mocha test runner options](https://mochajs.org/#configuring-mocha-nodejs), additional [reporters](https://codecept.io/reports/#xml) can be configured here. Example: ```js mocha: { "mocha-junit-reporter": { stdout: "./output/console.log", options: { mochaFile: "./output/result.xml", attachments: true //add screenshot for a failed test } } } ``` |
23
+ | `noGlobals?` | `boolean` | Disable registering global functions (Before, Scenario, etc). Not recommended |
24
+ | `output` | `string` | Where to store failure screenshots, artifacts, etc |
25
+ | `plugins?` | `any` | [Enabled plugins](https://codecept.io/plugins/) |
26
+ | `require?` | `string`[] | Require additional JS modules. https://codecept.io/configuration/#require Example: ``` require: ["ts-node/register", "should"] ``` |
27
+ | `teardown` | `Function` \| `boolean` \| `string` | Execute JS code after tests are run. https://codecept.io/bootstrap/ Can be either JS module file or async function: ```js teardown: async () => server.stop(), ``` or ```js teardown: 'teardown.js', ``` |
28
+ | `teardownAll` | `Function` \| `boolean` \| `string` | Execute JS code after finishing tests in parallel mode. https://codecept.io/bootstrap/#bootstrapall-teardownall |
29
+ | `tests` | `string` | Pattern to locate CodeceptJS tests. Allows to enter glob pattern or an Array<string> of patterns to match tests / test file names. For tests in JavaScript: ```js tests: 'tests/**.test.js' ``` For tests in TypeScript: ```js tests: 'tests/**.test.ts' ``` |
30
+ | `timeout?` | `number` | Set default tests timeout in seconds. Tests will be killed on no response after timeout. ```js timeout: 20, ``` |
31
+ | `translation?` | `string` | Enable localized test commands https://codecept.io/translation/ |
32
+
30
33
 
31
34
 
32
35
  ## Require