codeceptjs 3.3.0-beta.5 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +6 -1
  3. package/docs/api.md +45 -30
  4. package/docs/bdd.md +1 -0
  5. package/docs/best.md +1 -1
  6. package/docs/build/ApiDataFactory.js +4 -3
  7. package/docs/build/Appium.js +53 -48
  8. package/docs/build/GraphQL.js +4 -2
  9. package/docs/build/GraphQLDataFactory.js +3 -3
  10. package/docs/build/JSONResponse.js +1 -1
  11. package/docs/build/Nightmare.js +101 -72
  12. package/docs/build/Playwright.js +166 -113
  13. package/docs/build/Protractor.js +72 -34
  14. package/docs/build/Puppeteer.js +143 -100
  15. package/docs/build/REST.js +5 -2
  16. package/docs/build/TestCafe.js +97 -66
  17. package/docs/build/WebDriver.js +183 -135
  18. package/docs/changelog.md +99 -0
  19. package/docs/custom-helpers.md +1 -1
  20. package/docs/data.md +2 -2
  21. package/docs/email.md +5 -0
  22. package/docs/helpers/ApiDataFactory.md +7 -3
  23. package/docs/helpers/Appium.md +217 -175
  24. package/docs/helpers/GraphQL.md +6 -0
  25. package/docs/helpers/GraphQLDataFactory.md +3 -3
  26. package/docs/helpers/JSONResponse.md +1 -1
  27. package/docs/helpers/MockRequest.md +8 -6
  28. package/docs/helpers/Nightmare.md +98 -45
  29. package/docs/helpers/Playwright.md +151 -59
  30. package/docs/helpers/Puppeteer.md +103 -26
  31. package/docs/helpers/REST.md +1 -1
  32. package/docs/helpers/TestCafe.md +77 -22
  33. package/docs/helpers/WebDriver.md +150 -62
  34. package/docs/index.md +1 -1
  35. package/docs/locators.md +1 -1
  36. package/docs/videos.md +2 -2
  37. package/docs/webapi/amOnPage.mustache +2 -1
  38. package/docs/webapi/appendField.mustache +2 -1
  39. package/docs/webapi/attachFile.mustache +2 -1
  40. package/docs/webapi/checkOption.mustache +2 -1
  41. package/docs/webapi/clearCookie.mustache +2 -1
  42. package/docs/webapi/clearField.mustache +1 -0
  43. package/docs/webapi/click.mustache +2 -1
  44. package/docs/webapi/clickLink.mustache +2 -1
  45. package/docs/webapi/closeCurrentTab.mustache +6 -4
  46. package/docs/webapi/closeOtherTabs.mustache +6 -4
  47. package/docs/webapi/dontSee.mustache +1 -0
  48. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -0
  49. package/docs/webapi/dontSeeCookie.mustache +2 -1
  50. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +2 -1
  51. package/docs/webapi/dontSeeElement.mustache +2 -1
  52. package/docs/webapi/dontSeeElementInDOM.mustache +2 -1
  53. package/docs/webapi/dontSeeInCurrentUrl.mustache +2 -1
  54. package/docs/webapi/dontSeeInField.mustache +2 -1
  55. package/docs/webapi/dontSeeInSource.mustache +1 -0
  56. package/docs/webapi/dontSeeInTitle.mustache +2 -1
  57. package/docs/webapi/doubleClick.mustache +1 -0
  58. package/docs/webapi/downloadFile.mustache +2 -1
  59. package/docs/webapi/dragAndDrop.mustache +1 -0
  60. package/docs/webapi/dragSlider.mustache +2 -1
  61. package/docs/webapi/executeAsyncScript.mustache +1 -1
  62. package/docs/webapi/executeScript.mustache +1 -1
  63. package/docs/webapi/fillField.mustache +1 -0
  64. package/docs/webapi/forceClick.mustache +1 -0
  65. package/docs/webapi/forceRightClick.mustache +1 -0
  66. package/docs/webapi/grabDataFromPerformanceTiming.mustache +2 -1
  67. package/docs/webapi/moveCursorTo.mustache +1 -0
  68. package/docs/webapi/openNewTab.mustache +6 -4
  69. package/docs/webapi/pressKey.mustache +2 -1
  70. package/docs/webapi/pressKeyDown.mustache +1 -0
  71. package/docs/webapi/pressKeyUp.mustache +1 -0
  72. package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -0
  73. package/docs/webapi/refreshPage.mustache +1 -0
  74. package/docs/webapi/resizeWindow.mustache +2 -1
  75. package/docs/webapi/rightClick.mustache +1 -0
  76. package/docs/webapi/saveElementScreenshot.mustache +1 -0
  77. package/docs/webapi/saveScreenshot.mustache +2 -1
  78. package/docs/webapi/say.mustache +2 -1
  79. package/docs/webapi/scrollIntoView.mustache +1 -0
  80. package/docs/webapi/scrollPageToBottom.mustache +1 -0
  81. package/docs/webapi/scrollPageToTop.mustache +1 -0
  82. package/docs/webapi/scrollTo.mustache +2 -1
  83. package/docs/webapi/see.mustache +2 -1
  84. package/docs/webapi/seeAttributesOnElements.mustache +2 -1
  85. package/docs/webapi/seeCheckboxIsChecked.mustache +1 -0
  86. package/docs/webapi/seeCookie.mustache +1 -0
  87. package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -1
  88. package/docs/webapi/seeCurrentUrlEquals.mustache +2 -1
  89. package/docs/webapi/seeElement.mustache +2 -1
  90. package/docs/webapi/seeElementInDOM.mustache +1 -0
  91. package/docs/webapi/seeInCurrentUrl.mustache +2 -1
  92. package/docs/webapi/seeInField.mustache +1 -0
  93. package/docs/webapi/seeInPopup.mustache +1 -0
  94. package/docs/webapi/seeInSource.mustache +2 -1
  95. package/docs/webapi/seeInTitle.mustache +2 -1
  96. package/docs/webapi/seeNumberOfElements.mustache +1 -0
  97. package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -0
  98. package/docs/webapi/seeTextEquals.mustache +2 -1
  99. package/docs/webapi/seeTitleEquals.mustache +6 -5
  100. package/docs/webapi/selectOption.mustache +1 -0
  101. package/docs/webapi/setCookie.mustache +1 -0
  102. package/docs/webapi/setGeoLocation.mustache +1 -0
  103. package/docs/webapi/switchTo.mustache +2 -1
  104. package/docs/webapi/switchToNextTab.mustache +8 -7
  105. package/docs/webapi/switchToPreviousTab.mustache +8 -7
  106. package/docs/webapi/type.mustache +1 -0
  107. package/docs/webapi/uncheckOption.mustache +2 -1
  108. package/docs/webapi/wait.mustache +2 -1
  109. package/docs/webapi/waitForClickable.mustache +2 -1
  110. package/docs/webapi/waitForDetached.mustache +2 -1
  111. package/docs/webapi/waitForElement.mustache +2 -1
  112. package/docs/webapi/waitForEnabled.mustache +2 -1
  113. package/docs/webapi/waitForFunction.mustache +1 -0
  114. package/docs/webapi/waitForInvisible.mustache +2 -1
  115. package/docs/webapi/waitForText.mustache +2 -1
  116. package/docs/webapi/waitForValue.mustache +1 -0
  117. package/docs/webapi/waitForVisible.mustache +1 -0
  118. package/docs/webapi/waitInUrl.mustache +2 -1
  119. package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -1
  120. package/docs/webapi/waitToHide.mustache +2 -1
  121. package/docs/webapi/waitUrlEquals.mustache +2 -1
  122. package/lib/command/definitions.js +9 -0
  123. package/lib/command/run.js +2 -2
  124. package/lib/command/workers/runTests.js +40 -0
  125. package/lib/helper/ApiDataFactory.js +4 -3
  126. package/lib/helper/Appium.js +2 -7
  127. package/lib/helper/GraphQL.js +4 -2
  128. package/lib/helper/GraphQLDataFactory.js +3 -3
  129. package/lib/helper/JSONResponse.js +1 -1
  130. package/lib/helper/Playwright.js +28 -17
  131. package/lib/helper/REST.js +5 -2
  132. package/lib/helper/WebDriver.js +4 -0
  133. package/lib/interfaces/bdd.js +5 -0
  134. package/lib/listener/steps.js +1 -0
  135. package/lib/plugin/fakerTransform.js +1 -1
  136. package/lib/plugin/stepByStepReport.js +8 -6
  137. package/lib/workers.js +12 -0
  138. package/package.json +3 -3
  139. package/typings/types.d.ts +578 -109
package/docs/changelog.md CHANGED
@@ -7,6 +7,105 @@ layout: Section
7
7
 
8
8
  # Releases
9
9
 
10
+ ## 3.3.2
11
+
12
+ * **[REST]** Fixed override of headers/token in `haveRequestHeaders()` and `amBearerAuthenticated()`. See [#3304](https://github.com/codeceptjs/CodeceptJS/issues/3304) by **[mirao](https://github.com/mirao)**
13
+ * Reverted typings change introduced in [#3245](https://github.com/codeceptjs/CodeceptJS/issues/3245). [More details on this](https://twitter.com/CodeceptJS/status/1519725963856207873)
14
+
15
+ ## 3.3.1
16
+
17
+ 🛩️ Features:
18
+
19
+ * Add option to avoid duplicate gherkin step definitions ([#3257](https://github.com/codeceptjs/CodeceptJS/issues/3257)) - **[raywiis](https://github.com/raywiis)**
20
+ * Added `step.*` for run-workers [#3272](https://github.com/codeceptjs/CodeceptJS/issues/3272). Thanks to **[abhimanyupandian](https://github.com/abhimanyupandian)**
21
+ * Fixed loading tests for `codecept run` using glob patterns. By **[jayudey-wf](https://github.com/jayudey-wf)**
22
+
23
+ ```
24
+ npx codeceptjs run test-dir/*"
25
+ ```
26
+
27
+ * **[Playwright]** **Possible breaking change.** By default `timeout` is changed to 5000ms. The value set in 3.3.0 was too low. Please set `timeout` explicitly to not depend on release values.
28
+ * **[Playwright]** Added for color scheme option by **[PeterNgTr](https://github.com/PeterNgTr)**
29
+
30
+ ```js
31
+ helpers: {
32
+ Playwright : {
33
+ url: "http://localhost",
34
+ colorScheme: "dark",
35
+ }
36
+ }
37
+ ```
38
+
39
+
40
+ 🐛 Bugfixes:
41
+
42
+ * **[Playwright]** Fixed `Cannot read property 'video' of undefined`
43
+ * Fixed haveRequestHeaders() and amBearerAuthenticated() of REST helper ([#3260](https://github.com/codeceptjs/CodeceptJS/issues/3260)) - **[mirao](https://github.com/mirao)**
44
+ * Fixed: allure attachment fails if screenshot failed [#3298](https://github.com/codeceptjs/CodeceptJS/issues/3298) by **[ruudvanderweijde](https://github.com/ruudvanderweijde)**
45
+ * Fixed [#3105](https://github.com/codeceptjs/CodeceptJS/issues/3105) using autoLogin() plugin with TypeScript. Fix [#3290](https://github.com/codeceptjs/CodeceptJS/issues/3290) by **[PeterNgTr](https://github.com/PeterNgTr)**
46
+ * **[Playwright]** Added extra params for click and dragAndDrop to type definitions by **[mirao](https://github.com/mirao)**
47
+
48
+
49
+ 📖 Documentation
50
+ * Improving the typings in many places
51
+ * Improving the return type of helpers for TS users ([#3245](https://github.com/codeceptjs/CodeceptJS/issues/3245)) - **[nlespiaucq](https://github.com/nlespiaucq)**
52
+
53
+ 🇺🇦 Added #StandWithUkraine hashtag notice to CLI
54
+
55
+ ## 3.3.0
56
+
57
+ 🛩️ Features:
58
+
59
+ * [**API Testing introduced**](/api)
60
+ * Introduced [`JSONResponse`](/helpers/JSONResponse) helper which connects to REST, GraphQL or Playwright helper
61
+ * **[REST]** Added `amBearerAuthenticated` method
62
+ * **[REST]** Added `haveRequestHeaders` method
63
+ * Added dependency on `joi` and `chai`
64
+ * **[Playwright]** Added `timeout` option to set [timeout](https://playwright.dev/docs/api/class-page#page-set-default-timeout) for all Playwright actions. If an action fails, Playwright keeps retrying it for a time set by timeout.
65
+ * **[Playwright]** **Possible breaking change.** By default `timeout` is set to 1000ms. *Previous default was set by Playwright internally to 30s. This was causing contradiction to CodeceptJS retries, so triggered up to 3 retries for 30s of time. This timeout option was lowered so retryFailedStep plugin would not cause long delays.*
66
+ * **[Playwright]** Updated `restart` config option to include 3 restart strategies:
67
+ * '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.
68
+ * 'browser' or **true** - closes browser and opens it again between tests.
69
+ * '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 prior CodeceptJS 3.1
70
+ * **[Playwright]** Extended methods to provide more options from engine. These methods were updated so additional options can be be passed as the last argument:
71
+ * [`click`](/helpers/Playwright#click)
72
+ * [`dragAndDrop`](/helpers/Playwright#dragAndDrop)
73
+ * [`checkOption`](/helpers/Playwright#checkOption)
74
+ * [`uncheckOption`](/helpers/Playwright#uncheckOption)
75
+
76
+ ```js
77
+ // use Playwright click options as 3rd argument
78
+ I.click('canvas', '.model', { position: { x: 20, y: 40 } })
79
+ // check option also has options
80
+ I.checkOption('Agree', '.signup', { position: { x: 5, y: 5 } })
81
+ ```
82
+
83
+ * `eachElement` plugin introduced. It allows you to iterate over elements and perform some action on them using direct engines API
84
+
85
+ ```js
86
+ await eachElement('click all links in .list', '.list a', (el) => {
87
+ await el.click();
88
+ })
89
+ ```
90
+ * **[Playwright]** Added support to `playwright-core` package if `playwright` is not installed. See [#3190](https://github.com/codeceptjs/CodeceptJS/issues/3190), fixes [#2663](https://github.com/codeceptjs/CodeceptJS/issues/2663).
91
+ * **[Playwright]** Added `makeApiRequest` action to perform API requests. Requires Playwright >= 1.18
92
+ * Added support to `codecept.config.js` for name consistency across other JS tools. See motivation at [#3195](https://github.com/codeceptjs/CodeceptJS/issues/3195) by **[JiLiZART](https://github.com/JiLiZART)**
93
+ * **[ApiDataFactory]** Added options arg to `have` method. See [#3197](https://github.com/codeceptjs/CodeceptJS/issues/3197) by **[JJlokidoki](https://github.com/JJlokidoki)**
94
+ * Improved pt-br translations to include keywords: 'Funcionalidade', 'Cenário', 'Antes', 'Depois', 'AntesDaSuite', 'DepoisDaSuite'. See [#3206](https://github.com/codeceptjs/CodeceptJS/issues/3206) by **[danilolutz](https://github.com/danilolutz)**
95
+ * [allure plugin] Introduced `addStep` method to add comments and attachments. See [#3104](https://github.com/codeceptjs/CodeceptJS/issues/3104) by **[EgorBodnar](https://github.com/EgorBodnar)**
96
+
97
+ 🐛 Bugfixes:
98
+
99
+ * Fixed [#3212](https://github.com/codeceptjs/CodeceptJS/issues/3212): using Regex flags for Cucumber steps. See [#3214](https://github.com/codeceptjs/CodeceptJS/issues/3214) by **[anils92](https://github.com/anils92)**
100
+
101
+ 📖 Documentation
102
+
103
+ * Added [Testomat.io reporter](/reports#testomatio)
104
+ * Added [api testing](/api) guides
105
+ * Added [internal api](/internal-api) guides
106
+ * **[Appium]** Fixed documentation for `performSwipe`
107
+ * **[Playwright]** update docs for `usePlaywrightTo` method by **[dbudzins](https://github.com/dbudzins)**
108
+
10
109
  ## 3.2.3
11
110
 
12
111
  * Documentation improvements by **[maojunxyz](https://github.com/maojunxyz)**
@@ -7,7 +7,7 @@ title: Custom Helpers
7
7
 
8
8
  Helper is the core concept of CodeceptJS. Helper is a wrapper on top of various libraries providing unified interface around them. When `I` object is used in tests it delegates execution of its functions to currently enabled helper classes.
9
9
 
10
- Use Helpers to introduce low-level API to your tests without polluting test scenarios. Helpers can also be used to share functionality accross different project and installed as npm packages.
10
+ Use Helpers to introduce low-level API to your tests without polluting test scenarios. Helpers can also be used to share functionality across different project and installed as npm packages.
11
11
 
12
12
  ## Development
13
13
 
package/docs/data.md CHANGED
@@ -206,7 +206,7 @@ See the example providing a factory for User generation:
206
206
  ```js
207
207
  // factories/post.js
208
208
  var Factory = require('rosie').Factory;
209
- var faker = require('faker');
209
+ var faker = require('@faker-js/faker');
210
210
 
211
211
  module.exports = new Factory()
212
212
  .attr('name', () => faker.name.findName())
@@ -262,7 +262,7 @@ See the example providing a factory for User generation:
262
262
  ```js
263
263
  // factories/post.js
264
264
  var Factory = require('rosie').Factory;
265
- var faker = require('faker');
265
+ var faker = require('@faker-js/faker');
266
266
 
267
267
  module.exports = new Factory((buildObj) => {
268
268
  return {
package/docs/email.md CHANGED
@@ -145,6 +145,8 @@ After opening an email assertion methods are available.
145
145
  * `seeEmailIsFrom`
146
146
  * `seeInEmailBody`
147
147
  * `dontSeeInEmailBody`
148
+ * `seeNumberOfEmailAttachments`
149
+ * `seeEmailAttachment`
148
150
 
149
151
  And here is an example of their usage:
150
152
 
@@ -153,6 +155,9 @@ I.waitForLatestEmail()
153
155
  I.seeEmailIsFrom('@mysite.com');
154
156
  I.seeInEmailSubject('Awesome Proposal!');
155
157
  I.seeInEmailBody('To unsubscribe click here');
158
+ I.seeNumberOfEmailAttachments(2);
159
+ I.seeEmailAttachment('Attachment_1.pdf')
160
+ I.seeEmailAttachment('Attachment_2.pdf')
156
161
  ```
157
162
 
158
163
  > More methods are listed in [helper's API reference](https://github.com/codeceptjs/mailslurp-helper/blob/master/README.md#api)
@@ -43,7 +43,7 @@ To make this work you need
43
43
  Install [Rosie][1] and [Faker][2] libraries.
44
44
 
45
45
  ```sh
46
- npm i rosie faker --save-dev
46
+ npm i rosie @faker-js/faker --save-dev
47
47
  ```
48
48
 
49
49
  Create a factory file for a resource.
@@ -53,8 +53,8 @@ See the example for Posts factories:
53
53
  ```js
54
54
  // tests/factories/posts.js
55
55
 
56
- var Factory = require('rosie').Factory;
57
- var faker = require('faker');
56
+ const Factory = require('rosie').Factory;
57
+ const faker = require('@faker-js/faker');
58
58
 
59
59
  module.exports = new Factory()
60
60
  // no need to set id, it will be set by REST API
@@ -231,6 +231,8 @@ I.have('user', { }, { age: 33, height: 55 })
231
231
  - `params` **any** predefined parameters
232
232
  - `options` **any** options for programmatically generate the attributes
233
233
 
234
+ Returns **[Promise][5]<any>**
235
+
234
236
  ### haveMultiple
235
237
 
236
238
  Generates bunch of records and saves multiple API requests to store them.
@@ -260,3 +262,5 @@ I.haveMultiple('post', 3, { author: 'davert' }, { publish_date: '01.01.1997' });
260
262
  [3]: http://codecept.io/helpers/REST/
261
263
 
262
264
  [4]: https://github.com/axios/axios#request-config
265
+
266
+ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise