codeceptjs 3.5.12-beta.5 → 3.5.12-beta.6

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 (214) hide show
  1. package/lib/helper/Playwright.js +41 -22
  2. package/lib/helper/Puppeteer.js +23 -6
  3. package/lib/helper/WebDriver.js +23 -4
  4. package/lib/helper/errors/ElementAssertion.js +38 -0
  5. package/lib/locator.js +4 -13
  6. package/package.json +8 -10
  7. package/docs/advanced.md +0 -351
  8. package/docs/ai.md +0 -248
  9. package/docs/api.md +0 -323
  10. package/docs/basics.md +0 -979
  11. package/docs/bdd.md +0 -539
  12. package/docs/best.md +0 -237
  13. package/docs/books.md +0 -37
  14. package/docs/bootstrap.md +0 -135
  15. package/docs/build/ApiDataFactory.js +0 -410
  16. package/docs/build/Appium.js +0 -2027
  17. package/docs/build/Expect.js +0 -422
  18. package/docs/build/FileSystem.js +0 -228
  19. package/docs/build/GraphQL.js +0 -229
  20. package/docs/build/GraphQLDataFactory.js +0 -309
  21. package/docs/build/JSONResponse.js +0 -338
  22. package/docs/build/Mochawesome.js +0 -71
  23. package/docs/build/Nightmare.js +0 -2152
  24. package/docs/build/OpenAI.js +0 -126
  25. package/docs/build/Playwright.js +0 -5110
  26. package/docs/build/Protractor.js +0 -2706
  27. package/docs/build/Puppeteer.js +0 -3905
  28. package/docs/build/REST.js +0 -344
  29. package/docs/build/TestCafe.js +0 -2125
  30. package/docs/build/WebDriver.js +0 -4240
  31. package/docs/changelog.md +0 -2572
  32. package/docs/commands.md +0 -266
  33. package/docs/community-helpers.md +0 -58
  34. package/docs/configuration.md +0 -157
  35. package/docs/continuous-integration.md +0 -22
  36. package/docs/custom-helpers.md +0 -306
  37. package/docs/data.md +0 -379
  38. package/docs/detox.md +0 -235
  39. package/docs/docker.md +0 -136
  40. package/docs/email.md +0 -183
  41. package/docs/examples.md +0 -149
  42. package/docs/helpers/ApiDataFactory.md +0 -266
  43. package/docs/helpers/Appium.md +0 -1374
  44. package/docs/helpers/Detox.md +0 -586
  45. package/docs/helpers/Expect.md +0 -275
  46. package/docs/helpers/FileSystem.md +0 -152
  47. package/docs/helpers/GraphQL.md +0 -151
  48. package/docs/helpers/GraphQLDataFactory.md +0 -226
  49. package/docs/helpers/JSONResponse.md +0 -254
  50. package/docs/helpers/Mochawesome.md +0 -8
  51. package/docs/helpers/MockRequest.md +0 -377
  52. package/docs/helpers/Nightmare.md +0 -1305
  53. package/docs/helpers/OpenAI.md +0 -70
  54. package/docs/helpers/Playwright.md +0 -2759
  55. package/docs/helpers/Polly.md +0 -44
  56. package/docs/helpers/Protractor.md +0 -1769
  57. package/docs/helpers/Puppeteer-firefox.md +0 -86
  58. package/docs/helpers/Puppeteer.md +0 -2317
  59. package/docs/helpers/REST.md +0 -218
  60. package/docs/helpers/TestCafe.md +0 -1321
  61. package/docs/helpers/WebDriver.md +0 -2547
  62. package/docs/hooks.md +0 -340
  63. package/docs/index.md +0 -111
  64. package/docs/installation.md +0 -75
  65. package/docs/internal-api.md +0 -266
  66. package/docs/locators.md +0 -339
  67. package/docs/mobile-react-native-locators.md +0 -67
  68. package/docs/mobile.md +0 -338
  69. package/docs/pageobjects.md +0 -291
  70. package/docs/parallel.md +0 -400
  71. package/docs/playwright.md +0 -632
  72. package/docs/plugins.md +0 -1259
  73. package/docs/puppeteer.md +0 -316
  74. package/docs/quickstart.md +0 -162
  75. package/docs/react.md +0 -70
  76. package/docs/reports.md +0 -392
  77. package/docs/secrets.md +0 -36
  78. package/docs/shadow.md +0 -68
  79. package/docs/shared/keys.mustache +0 -31
  80. package/docs/shared/react.mustache +0 -1
  81. package/docs/testcafe.md +0 -174
  82. package/docs/translation.md +0 -247
  83. package/docs/tutorial.md +0 -271
  84. package/docs/typescript.md +0 -180
  85. package/docs/ui.md +0 -59
  86. package/docs/videos.md +0 -28
  87. package/docs/visual.md +0 -202
  88. package/docs/vue.md +0 -143
  89. package/docs/webapi/amOnPage.mustache +0 -11
  90. package/docs/webapi/appendField.mustache +0 -11
  91. package/docs/webapi/attachFile.mustache +0 -12
  92. package/docs/webapi/blur.mustache +0 -18
  93. package/docs/webapi/checkOption.mustache +0 -13
  94. package/docs/webapi/clearCookie.mustache +0 -9
  95. package/docs/webapi/clearField.mustache +0 -9
  96. package/docs/webapi/click.mustache +0 -25
  97. package/docs/webapi/clickLink.mustache +0 -8
  98. package/docs/webapi/closeCurrentTab.mustache +0 -7
  99. package/docs/webapi/closeOtherTabs.mustache +0 -8
  100. package/docs/webapi/dontSee.mustache +0 -11
  101. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +0 -10
  102. package/docs/webapi/dontSeeCookie.mustache +0 -8
  103. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +0 -10
  104. package/docs/webapi/dontSeeElement.mustache +0 -8
  105. package/docs/webapi/dontSeeElementInDOM.mustache +0 -8
  106. package/docs/webapi/dontSeeInCurrentUrl.mustache +0 -4
  107. package/docs/webapi/dontSeeInField.mustache +0 -11
  108. package/docs/webapi/dontSeeInSource.mustache +0 -8
  109. package/docs/webapi/dontSeeInTitle.mustache +0 -8
  110. package/docs/webapi/doubleClick.mustache +0 -13
  111. package/docs/webapi/downloadFile.mustache +0 -12
  112. package/docs/webapi/dragAndDrop.mustache +0 -9
  113. package/docs/webapi/dragSlider.mustache +0 -11
  114. package/docs/webapi/executeAsyncScript.mustache +0 -24
  115. package/docs/webapi/executeScript.mustache +0 -26
  116. package/docs/webapi/fillField.mustache +0 -16
  117. package/docs/webapi/focus.mustache +0 -13
  118. package/docs/webapi/forceClick.mustache +0 -28
  119. package/docs/webapi/forceRightClick.mustache +0 -18
  120. package/docs/webapi/grabAllWindowHandles.mustache +0 -7
  121. package/docs/webapi/grabAttributeFrom.mustache +0 -10
  122. package/docs/webapi/grabAttributeFromAll.mustache +0 -9
  123. package/docs/webapi/grabBrowserLogs.mustache +0 -9
  124. package/docs/webapi/grabCookie.mustache +0 -11
  125. package/docs/webapi/grabCssPropertyFrom.mustache +0 -11
  126. package/docs/webapi/grabCssPropertyFromAll.mustache +0 -10
  127. package/docs/webapi/grabCurrentUrl.mustache +0 -9
  128. package/docs/webapi/grabCurrentWindowHandle.mustache +0 -6
  129. package/docs/webapi/grabDataFromPerformanceTiming.mustache +0 -20
  130. package/docs/webapi/grabElementBoundingRect.mustache +0 -20
  131. package/docs/webapi/grabGeoLocation.mustache +0 -8
  132. package/docs/webapi/grabHTMLFrom.mustache +0 -10
  133. package/docs/webapi/grabHTMLFromAll.mustache +0 -9
  134. package/docs/webapi/grabNumberOfOpenTabs.mustache +0 -8
  135. package/docs/webapi/grabNumberOfVisibleElements.mustache +0 -9
  136. package/docs/webapi/grabPageScrollPosition.mustache +0 -8
  137. package/docs/webapi/grabPopupText.mustache +0 -5
  138. package/docs/webapi/grabSource.mustache +0 -8
  139. package/docs/webapi/grabTextFrom.mustache +0 -10
  140. package/docs/webapi/grabTextFromAll.mustache +0 -9
  141. package/docs/webapi/grabTitle.mustache +0 -8
  142. package/docs/webapi/grabValueFrom.mustache +0 -9
  143. package/docs/webapi/grabValueFromAll.mustache +0 -8
  144. package/docs/webapi/grabWebElement.mustache +0 -9
  145. package/docs/webapi/grabWebElements.mustache +0 -9
  146. package/docs/webapi/moveCursorTo.mustache +0 -12
  147. package/docs/webapi/openNewTab.mustache +0 -7
  148. package/docs/webapi/pressKey.mustache +0 -12
  149. package/docs/webapi/pressKeyDown.mustache +0 -12
  150. package/docs/webapi/pressKeyUp.mustache +0 -12
  151. package/docs/webapi/pressKeyWithKeyNormalization.mustache +0 -60
  152. package/docs/webapi/refreshPage.mustache +0 -6
  153. package/docs/webapi/resizeWindow.mustache +0 -6
  154. package/docs/webapi/rightClick.mustache +0 -14
  155. package/docs/webapi/saveElementScreenshot.mustache +0 -10
  156. package/docs/webapi/saveScreenshot.mustache +0 -12
  157. package/docs/webapi/say.mustache +0 -10
  158. package/docs/webapi/scrollIntoView.mustache +0 -11
  159. package/docs/webapi/scrollPageToBottom.mustache +0 -6
  160. package/docs/webapi/scrollPageToTop.mustache +0 -6
  161. package/docs/webapi/scrollTo.mustache +0 -12
  162. package/docs/webapi/see.mustache +0 -11
  163. package/docs/webapi/seeAttributesOnElements.mustache +0 -9
  164. package/docs/webapi/seeCheckboxIsChecked.mustache +0 -10
  165. package/docs/webapi/seeCookie.mustache +0 -8
  166. package/docs/webapi/seeCssPropertiesOnElements.mustache +0 -9
  167. package/docs/webapi/seeCurrentUrlEquals.mustache +0 -11
  168. package/docs/webapi/seeElement.mustache +0 -8
  169. package/docs/webapi/seeElementInDOM.mustache +0 -8
  170. package/docs/webapi/seeInCurrentUrl.mustache +0 -8
  171. package/docs/webapi/seeInField.mustache +0 -12
  172. package/docs/webapi/seeInPopup.mustache +0 -8
  173. package/docs/webapi/seeInSource.mustache +0 -7
  174. package/docs/webapi/seeInTitle.mustache +0 -8
  175. package/docs/webapi/seeNumberOfElements.mustache +0 -11
  176. package/docs/webapi/seeNumberOfVisibleElements.mustache +0 -10
  177. package/docs/webapi/seeTextEquals.mustache +0 -9
  178. package/docs/webapi/seeTitleEquals.mustache +0 -8
  179. package/docs/webapi/selectOption.mustache +0 -21
  180. package/docs/webapi/setCookie.mustache +0 -16
  181. package/docs/webapi/setGeoLocation.mustache +0 -12
  182. package/docs/webapi/switchTo.mustache +0 -9
  183. package/docs/webapi/switchToNextTab.mustache +0 -10
  184. package/docs/webapi/switchToPreviousTab.mustache +0 -10
  185. package/docs/webapi/type.mustache +0 -21
  186. package/docs/webapi/uncheckOption.mustache +0 -13
  187. package/docs/webapi/wait.mustache +0 -8
  188. package/docs/webapi/waitForClickable.mustache +0 -11
  189. package/docs/webapi/waitForDetached.mustache +0 -10
  190. package/docs/webapi/waitForElement.mustache +0 -11
  191. package/docs/webapi/waitForEnabled.mustache +0 -6
  192. package/docs/webapi/waitForFunction.mustache +0 -17
  193. package/docs/webapi/waitForInvisible.mustache +0 -10
  194. package/docs/webapi/waitForNumberOfTabs.mustache +0 -9
  195. package/docs/webapi/waitForText.mustache +0 -13
  196. package/docs/webapi/waitForValue.mustache +0 -10
  197. package/docs/webapi/waitForVisible.mustache +0 -10
  198. package/docs/webapi/waitInUrl.mustache +0 -9
  199. package/docs/webapi/waitNumberOfVisibleElements.mustache +0 -10
  200. package/docs/webapi/waitToHide.mustache +0 -10
  201. package/docs/webapi/waitUrlEquals.mustache +0 -10
  202. package/docs/webdriver.md +0 -701
  203. package/docs/wiki/Books-&-Posts.md +0 -27
  204. package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
  205. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
  206. package/docs/wiki/Examples.md +0 -145
  207. package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
  208. package/docs/wiki/Home.md +0 -16
  209. package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
  210. package/docs/wiki/Release-Process.md +0 -24
  211. package/docs/wiki/Roadmap.md +0 -23
  212. package/docs/wiki/Tests.md +0 -1393
  213. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
  214. package/docs/wiki/Videos.md +0 -19
package/docs/hooks.md DELETED
@@ -1,340 +0,0 @@
1
- ---
2
- permalink: /hooks
3
- title: Extending CodeceptJS
4
- ---
5
-
6
- # Extending
7
-
8
- CodeceptJS provides API to run custom code before and after the test and inject custom listeners into the event system.
9
-
10
-
11
- ## Plugins
12
-
13
- Plugins allow to use CodeceptJS internal API to extend functionality. Use internal event dispatcher, container, output, promise recorder, to create your own reporters, test listeners, etc.
14
-
15
- CodeceptJS includes [built-in plugins](/plugins/) which extend basic functionality and can be turned on and off on purpose. Taking them as [examples](https://github.com/codeceptjs/CodeceptJS/tree/master/lib/plugin) you can develop your custom plugins.
16
-
17
- A plugin is a basic JS module returning a function. Plugins can have individual configs which are passed into this function:
18
-
19
- ```js
20
- const defaultConfig = {
21
- someDefaultOption: true
22
- }
23
-
24
- module.exports = function(config) {
25
- config = Object.assign(defaultConfig, config);
26
- // do stuff
27
- }
28
- ```
29
-
30
- Plugin can register event listeners or hook into promise chain with recorder. See [API reference](https://github.com/codeceptjs/CodeceptJS/tree/master/lib/helper).
31
-
32
- To enable your custom plugin in config add it to `plugins` section. Specify path to node module using `require`.
33
-
34
- ```js
35
- "plugins": {
36
- "myPlugin": {
37
- "require": "./path/to/my/module",
38
- "enabled": true
39
- }
40
- }
41
- ```
42
-
43
- * `require` - specifies relative path to a plugin file. Path is relative to config file.
44
- * `enabled` - to enable this plugin.
45
-
46
- If a plugin is disabled (`enabled` is not set or false) this plugin can be enabled from command line:
47
-
48
- ```
49
- npx codeceptjs run --plugin myPlugin
50
- ```
51
-
52
- Several plugins can be enabled as well:
53
-
54
- ```
55
- npx codeceptjs run --plugin myPlugin,allure
56
- ```
57
-
58
- ### Example: Execute code for a specific group of tests
59
-
60
- If you need to execute some code before a group of tests, you can [mark these tests with a same tag](/advanced/#tags). Then to listen for tests where this tag is included (see [test object api](#test-object)).
61
-
62
- Let's say we need to populate database for a group of tests.
63
-
64
- ```js
65
- // populate database for slow tests
66
- const event = require('codeceptjs').event;
67
-
68
- module.exports = function() {
69
-
70
- event.dispatcher.on(event.test.before, function (test) {
71
-
72
- if (test.tags.indexOf('@populate') >= 0) {
73
- recorder.add('populate database', async () => {
74
- // populate database for this test
75
- })
76
- }
77
- });
78
- }
79
- ```
80
-
81
- ### Example: Check URL before running a test
82
-
83
- If you want to share bootstrap script or run multiple bootstraps, it's a good idea to wrap that script into a plugin.
84
- Plugin can also execute JS before tests but you need to use internal APIs to synchronize promises.
85
-
86
- ```js
87
- const { recorder } = require('codeceptjs');
88
-
89
- module.exports = function(options) {
90
-
91
- event.dispatcher.on(event.all.before, function () {
92
- recorder.startUnlessRunning(); // start recording promises
93
- recorder.add('do some async stuff', async () => {
94
- // your code
95
- });
96
- });
97
- }
98
- ```
99
-
100
- ## API
101
-
102
- **Use local CodeceptJS installation to get access to `codeceptjs` module**
103
-
104
- CodeceptJS provides an API which can be loaded via `require('codeceptjs')` when CodeceptJS is installed locally.
105
- These internal objects are available:
106
-
107
- * [`codecept`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/codecept.js): test runner class
108
- * [`config`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/config.js): current codecept config
109
- * [`event`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/event.js): event listener
110
- * [`recorder`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/recorder.js): global promise chain
111
- * [`output`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/output.js): internal printer
112
- * [`container`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/container.js): dependency injection container for tests, includes current helpers and support objects
113
- * [`helper`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/helper.js): basic helper class
114
- * [`actor`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/actor.js): basic actor (I) class
115
-
116
- [API reference](https://github.com/codeceptjs/CodeceptJS/tree/master/docs/api) is available on GitHub.
117
- Also please check the source code of corresponding modules.
118
-
119
- ### Event Listeners
120
-
121
- CodeceptJS provides a module with [event dispatcher and set of predefined events](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/event.js).
122
-
123
- It can be required from codeceptjs package if it is installed locally.
124
-
125
- ```js
126
- const event = require('codeceptjs').event;
127
-
128
- module.exports = function() {
129
-
130
- event.dispatcher.on(event.test.before, function (test) {
131
-
132
- console.log('--- I am before test --');
133
-
134
- });
135
- }
136
- ```
137
-
138
- Available events:
139
-
140
- * `event.test.before(test)` - *async* when `Before` hooks from helpers and from test is executed
141
- * `event.test.after(test)` - *async* after each test
142
- * `event.test.started(test)` - *sync* at the very beginning of a test. Passes a current test object.
143
- * `event.test.passed(test)` - *sync* when test passed
144
- * `event.test.failed(test, error)` - *sync* when test failed
145
- * `event.test.finished(test)` - *sync* when test finished
146
- * `event.suite.before(suite)` - *async* before a suite
147
- * `event.suite.after(suite)` - *async* after a suite
148
- * `event.step.before(step)` - *async* when the step is scheduled for execution
149
- * `event.step.after(step)` - *async* after a step
150
- * `event.step.started(step)` - *sync* when step starts.
151
- * `event.step.passed(step)` - *sync* when step passed.
152
- * `event.step.failed(step, err)` - *sync* when step failed.
153
- * `event.step.finished(step)` - *sync* when step finishes.
154
- * `event.step.comment(step)` - *sync* fired for comments like `I.say`.
155
- * `event.bddStep.before(bddStep)` - *async* when the gherkin step is scheduled for execution
156
- * `event.bddStep.after(bddStep)` - *async* after a gherkin step
157
- * `event.all.before` - before running tests
158
- * `event.all.after` - after running tests
159
- * `event.all.result` - when results are printed
160
-
161
- * *sync* - means that event is fired in the moment of action happens.
162
- * *async* - means that event is fired when an actions is scheduled. Use `recorder` to schedule your actions.
163
-
164
- For further reference look for [currently available listeners](https://github.com/codeceptjs/CodeceptJS/tree/master/lib/listener) using event system.
165
-
166
- #### Test Object
167
-
168
- Test events provide a test object with following fields:
169
-
170
- * `title` title of a test
171
- * `body` test function as a string
172
- * `opts` additional test options like retries, and others
173
- * `pending` true if test is scheduled for execution and false if a test has finished
174
- * `tags` array of tags for this test
175
- * `file` path to a file with a test.
176
- * `steps` array of executed steps (available only in `test.passed`, `test.failed`, `test.finished` event)
177
- * `skipInfo` additional test options when test skipped
178
- * * `message` string with reason for skip
179
- * * `description` string with test body
180
- and others
181
-
182
- #### Step Object
183
-
184
- Step events provide step objects with following fields:
185
-
186
- * `name` name of a step, like 'see', 'click', and others
187
- * `actor` current actor, in most cases it `I`
188
- * `helper` current helper instance used to execute this step
189
- * `helperMethod` corresponding helper method, in most cases is the same as `name`
190
- * `status` status of a step (passed or failed)
191
- * `prefix` if a step is executed inside `within` block contain within text, like: 'Within .js-signup-form'.
192
- * `args` passed arguments
193
-
194
- ### Recorder
195
-
196
- To inject asynchronous functions in a test or before/after a test you can subscribe to corresponding event and register a function inside a recorder object. [Recorder](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/recorder.js) represents a global promises chain.
197
-
198
- Provide a function description as a first parameter, function should return a promise:
199
-
200
- ```js
201
- const event = require('codeceptjs').event;
202
- const recorder = require('codeceptjs').recorder;
203
- module.exports = function() {
204
-
205
- event.dispatcher.on(event.test.before, function (test) {
206
-
207
- const request = require('request');
208
-
209
- recorder.add('create fixture data via API', function() {
210
- return new Promise((doneFn, errFn) => {
211
- request({
212
- baseUrl: 'http://api.site.com/',
213
- method: 'POST',
214
- url: '/users',
215
- json: { name: 'john', email: 'john@john.com' }
216
- }), (err, httpResponse, body) => {
217
- if (err) return errFn(err);
218
- doneFn();
219
- }
220
- });
221
- }
222
- });
223
- }
224
-
225
- ```
226
-
227
- Whenever you execute tests with `--verbose` option you will see registered events and promises executed by a recorder.
228
-
229
-
230
- ### Output
231
-
232
- Output module provides 4 verbosity levels. Depending on the mode you can have different information printed using corresponding functions.
233
-
234
- * `default`: prints basic information using `output.print`
235
- * `steps`: toggled by `--steps` option, prints step execution
236
- * `debug`: toggled by `--debug` option, prints steps, and debug information with `output.debug`
237
- * `verbose`: toggled by `--verbose` prints debug information and internal logs with `output.log`
238
-
239
- It is recommended to avoid `console.log` and use output.* methods for printing.
240
-
241
- ```js
242
- const output = require('codeceptjs').output;
243
-
244
- output.print('This is basic information');
245
- output.debug('This is debug information');
246
- output.log('This is verbose logging information');
247
- ```
248
-
249
- ### Container
250
-
251
- CodeceptJS has a dependency injection container with Helpers and Support objects.
252
- They can be retrieved from the container:
253
-
254
- ```js
255
- let container = require('codeceptjs').container;
256
-
257
- // get object with all helpers
258
- let helpers = container.helpers();
259
-
260
- // get helper by name
261
- let WebDriver = container.helpers('WebDriver');
262
-
263
- // get support objects
264
- let support = container.support();
265
-
266
- // get support object by name
267
- let UserPage = container.support('UserPage');
268
-
269
- // get all registered plugins
270
- let plugins = container.plugins();
271
- ```
272
-
273
- New objects can also be added to container in runtime:
274
-
275
- ```js
276
- let container = require('codeceptjs').container;
277
-
278
- container.append({
279
- helpers: { // add helper
280
- MyHelper: new MyHelper({ config1: 'val1' });
281
- },
282
- support: { // add page object
283
- UserPage: require('./pages/user');
284
- }
285
- })
286
- ```
287
-
288
- Container also contains current Mocha instance:
289
-
290
- ```js
291
- let mocha = container.mocha();
292
- ```
293
-
294
- ### Config
295
-
296
- CodeceptJS config can be accessed from `require('codeceptjs').config.get()`:
297
-
298
- ```js
299
-
300
- let config = require('codeceptjs').config.get();
301
-
302
- if (config.myKey == 'value') {
303
- // run hook
304
- }
305
- ```
306
-
307
-
308
- ## Custom Runner
309
-
310
- > 📺 [Watch this](https://www.youtube.com/watch?v=3eZtVL0Ad0A) material on YouTube
311
-
312
- CodeceptJS can be imported and used in custom runners.
313
- To initialize Codecept you need to create Config and Container objects.
314
-
315
- ```js
316
- const { codecept: Codecept } = require('codeceptjs');
317
-
318
- const config = { helpers: { WebDriver: { browser: 'chrome', url: 'http://localhost' } } };
319
- const opts = { steps: true };
320
-
321
- const codecept = new Codecept(config, options);
322
- codecept.init(testRoot);
323
-
324
- // run tests
325
- try {
326
- await codecept.bootstrap();
327
- codecept.loadTests('*_test.js');
328
- await codecept.run(test);
329
- } catch (err) {
330
- printError(err);
331
- process.exitCode = 1;
332
- } finally {
333
- await codecept.teardown();
334
- }
335
-
336
-
337
- ```
338
-
339
- In this way Codecept runner class can be extended.
340
-
package/docs/index.md DELETED
@@ -1,111 +0,0 @@
1
- ---
2
- layout: Landing
3
- sidebar: false
4
- actionText: Quickstart
5
- actionLink: /quickstart
6
- ---
7
-
8
- ::: slot pause
9
- ## Write a Test with Interactive Pause
10
-
11
- Open a browser on an empty page and pause execution.
12
- Type in commands to complete the test scenario.
13
-
14
- Successful commands will be saved into a file.
15
-
16
- ```js
17
- Scenario('Checkout test', ({ I }) => {
18
- I.amOnPage('/checkout');
19
- pause();
20
- })
21
- ```
22
- Copy commands from a file into a test. A test is ready!
23
- :::
24
-
25
- ::: slot write
26
- ## Write Tests from UI
27
-
28
- With CodeceptUI you can write your tests without closing a browser at all.
29
-
30
- Write initial commands and execute a test. An interactive pause will be started when test finishes.
31
-
32
- Share one browser accross test runs to save time on opening a browser.
33
- :::
34
-
35
-
36
- ::: slot autocomplete
37
- ## Powered with IntelliSense
38
-
39
- Use auto-completion writing a test fast.
40
-
41
- We use TypeScript type definitions that are automatically updated for custom steps and page objects.
42
-
43
- Writing a test in Visual Studio Code is as easy as picking a correct action and putting a parameter. It's really that nice!
44
-
45
- :::
46
-
47
-
48
- ::: slot ui
49
-
50
- ## Watch & Run Tests from UI
51
-
52
- We have a flexible interactive web runner which allows you to watch, debug, and write your tests in a web mode.
53
-
54
- Features:
55
-
56
- * Toggle headless/window mode with one click
57
- * See HTML snapshot of each step
58
- * Works with WebDriver, Puppeteer, TestCafe
59
- * Shows step-by-step execution
60
- * Integrated with your local IDE
61
-
62
- :::
63
-
64
-
65
- ::: slot run
66
-
67
- ## Print a Test
68
-
69
- Each executed step will be printed on screen when running with `--steps`
70
- ```js
71
- Scenario('Checkout test', ({ I }) => {
72
- I.amOnPage('/checkout');
73
- I.fillField('First name', 'davert');
74
- I.fillField('#lastName', 'mik');
75
- I.fillField('Promo code', '123345')
76
- //...
77
- })
78
- ```
79
-
80
- :::
81
-
82
- ::: slot code
83
-
84
- ## Realworld Example
85
-
86
- Can we use it for long scenarios? Sure!
87
-
88
- ```js
89
- const { faker } = require('@faker-js/faker'); // Use 3rd-party JS code
90
-
91
- Feature('Store');
92
-
93
- Scenario('Create a new store', async ({ I, login, SettingsPage }) => {
94
- const storeName = faker.lorem.slug();
95
- login('customer'); // Login customer from saved cookies
96
- SettingsPage.open(); // Use Page objects
97
- I.dontSee(storeName, '.settings'); // Assert text not present inside an element (located by CSS)
98
- I.click('Add', '.settings'); // Click link by text inside element (located by CSS)
99
- I.fillField('Store Name', storeName); // Fill fields by labels or placeholders
100
- I.fillField('Email', faker.internet.email());
101
- I.fillField('Telephone', faker.phone.phoneNumberFormat());
102
- I.selectInDropdown('Status', 'Active'); // Use custom methods
103
- I.retry(2).click('Create'); // Retry flaky step
104
- I.waitInUrl('/settings/setup/stores'); // Explicit waiter
105
- I.see(storeName, '.settings'); // Assert text present inside an element (located by CSS)
106
- const storeId = await I.grabTextFrom('#store-id'); // Use await to get information from browser
107
- I.say(`Created a store with ${storeId}`); // Print custom comments
108
- }).tag('stores');`;
109
-
110
- ```
111
- :::
@@ -1,75 +0,0 @@
1
- ---
2
- permalink: /installation
3
- title: Installation
4
- ---
5
-
6
- # Installation
7
-
8
- ## QuickStart Via Installer
9
-
10
- Creating a new project via [`create-codeceptjs` installer](https://github.com/codeceptjs/create-codeceptjs) is the simplest way to start
11
-
12
- Install CodeceptJS + Playwright into current directory
13
-
14
- ```
15
- npx create-codeceptjs .
16
- ```
17
-
18
- Install CodeceptJS + Puppeteer into current directory
19
-
20
- ```
21
- npx create-codeceptjs . --puppeteer
22
- ```
23
-
24
- Install CodeceptJS + webdriverio into current directory
25
-
26
- ```
27
- npx create-codeceptjs . --webdriverio
28
- ```
29
-
30
- Install CodeceptJS + webdriverio into `e2e-tests` directory:
31
-
32
- ```
33
- npx create-codeceptjs e2e-tests --webdriverio
34
- ```
35
-
36
- If you plan to use CodeceptJS for **API testing** only proceed to standard installation
37
-
38
- ## Standard Installation
39
-
40
- Open a directory where you want to install CodeceptJS tests.
41
- If it is an empty directory - create a new NPM package with
42
-
43
- ```
44
- npm init -y
45
- ```
46
-
47
- Install CodeceptJS with NPM:
48
-
49
- ```sh
50
- npx codeceptjs init
51
- ```
52
-
53
- After choosing default helper (Playwright, Puppeteer, WebDriver, etc) a corresponding package should be installed automatically.
54
-
55
- > If you face issues installing additional packages while running `npx codeceptjs init` command, install required packages manually using npm
56
-
57
- Unless you are using WebDriver - CodeceptJS is ready to go!
58
- For WebDriver installation Selenium Server is required 👇
59
-
60
- ## WebDriver
61
-
62
- WebDriver based helpers like WebDriver will require [Selenium Server](https://codecept.io/helpers/WebDriver/#selenium-installation) installed. They will also require ChromeDriver or GeckoDriver to run corresponding browsers.
63
-
64
- We recommend to install them manually or use NPM packages:
65
-
66
- [Selenium Standalone](https://www.npmjs.com/package/selenium-standalone) to install and run Selenium, ChromeDriver, Firefox Driver with one package.
67
-
68
-
69
- Alternatively, you can execute headless Selenium in [Docker](https://github.com/SeleniumHQ/docker-selenium) for headless browser testing.
70
-
71
- Launch Selenium with Chrome browser inside a Docker container:
72
-
73
- ```sh
74
- docker run --net=host selenium/standalone-chrome
75
- ```