codeceptjs 3.1.0 → 3.2.0

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 (71) hide show
  1. package/CHANGELOG.md +129 -3
  2. package/README.md +2 -3
  3. package/bin/codecept.js +1 -0
  4. package/docs/advanced.md +94 -60
  5. package/docs/basics.md +1 -1
  6. package/docs/bdd.md +55 -1
  7. package/docs/build/Appium.js +106 -34
  8. package/docs/build/FileSystem.js +1 -0
  9. package/docs/build/Nightmare.js +48 -48
  10. package/docs/build/Playwright.js +97 -94
  11. package/docs/build/Protractor.js +68 -81
  12. package/docs/build/Puppeteer.js +91 -93
  13. package/docs/build/REST.js +1 -0
  14. package/docs/build/TestCafe.js +44 -44
  15. package/docs/build/WebDriver.js +71 -95
  16. package/docs/changelog.md +144 -2
  17. package/docs/commands.md +21 -7
  18. package/docs/configuration.md +15 -2
  19. package/docs/custom-helpers.md +1 -36
  20. package/docs/helpers/Appium.md +97 -95
  21. package/docs/helpers/FileSystem.md +1 -1
  22. package/docs/helpers/Playwright.md +16 -18
  23. package/docs/helpers/Puppeteer.md +18 -18
  24. package/docs/helpers/REST.md +3 -1
  25. package/docs/helpers/WebDriver.md +3 -19
  26. package/docs/mobile-react-native-locators.md +3 -0
  27. package/docs/playwright.md +40 -0
  28. package/docs/plugins.md +185 -68
  29. package/docs/reports.md +23 -5
  30. package/lib/actor.js +20 -2
  31. package/lib/codecept.js +15 -2
  32. package/lib/command/info.js +1 -1
  33. package/lib/config.js +13 -1
  34. package/lib/container.js +3 -1
  35. package/lib/data/dataTableArgument.js +35 -0
  36. package/lib/helper/Appium.js +49 -4
  37. package/lib/helper/FileSystem.js +1 -0
  38. package/lib/helper/Playwright.js +35 -22
  39. package/lib/helper/Protractor.js +2 -14
  40. package/lib/helper/Puppeteer.js +20 -19
  41. package/lib/helper/REST.js +1 -0
  42. package/lib/helper/WebDriver.js +2 -16
  43. package/lib/index.js +2 -0
  44. package/lib/interfaces/featureConfig.js +3 -0
  45. package/lib/interfaces/gherkin.js +7 -1
  46. package/lib/interfaces/scenarioConfig.js +4 -0
  47. package/lib/listener/helpers.js +1 -0
  48. package/lib/listener/steps.js +21 -3
  49. package/lib/listener/timeout.js +71 -0
  50. package/lib/locator.js +3 -0
  51. package/lib/mochaFactory.js +13 -9
  52. package/lib/plugin/allure.js +6 -1
  53. package/lib/plugin/{puppeteerCoverage.js → coverage.js} +10 -22
  54. package/lib/plugin/customLocator.js +2 -2
  55. package/lib/plugin/retryTo.js +130 -0
  56. package/lib/plugin/screenshotOnFail.js +1 -0
  57. package/lib/plugin/stepByStepReport.js +7 -0
  58. package/lib/plugin/stepTimeout.js +90 -0
  59. package/lib/plugin/subtitles.js +88 -0
  60. package/lib/plugin/tryTo.js +1 -1
  61. package/lib/recorder.js +21 -8
  62. package/lib/step.js +7 -2
  63. package/lib/store.js +2 -0
  64. package/lib/ui.js +2 -2
  65. package/package.json +6 -7
  66. package/typings/index.d.ts +8 -1
  67. package/typings/types.d.ts +198 -82
  68. package/docs/angular.md +0 -325
  69. package/docs/helpers/Protractor.md +0 -1658
  70. package/docs/webapi/waitUntil.mustache +0 -11
  71. package/typings/Protractor.d.ts +0 -16
package/CHANGELOG.md CHANGED
@@ -1,10 +1,134 @@
1
+ ## 3.2.0
2
+
3
+ đŸ›Šī¸ Features:
4
+
5
+ **Timeouts implemented**
6
+ * global timeouts (via `timeout` config option).
7
+ * _Breaking change:_ timeout option expects **timeout in seconds**, not in miliseconds as it was previously.
8
+ * test timeouts (via `Scenario` and `Feature` options)
9
+ * _Breaking change:_ `Feature().timeout()` and `Scenario().timeout()` calls has no effect and are deprecated
10
+
11
+ ```js
12
+ // set timeout for every test in suite to 10 secs
13
+ Feature('tests with timeout', { timeout: 10 });
14
+
15
+ // set timeout for this test to 20 secs
16
+ Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {});
17
+ ```
18
+
19
+ * step timeouts (See #3059 by @nikocanvacom)
20
+
21
+ ```js
22
+ // set step timeout to 5 secs
23
+ I.limitTime(5).click('Link');
24
+ ```
25
+ * `stepTimeout` plugin introduced to automatically add timeouts for each step (#3059 by @nikocanvacom).
26
+
27
+ [**retryTo**](/plugins/#retryto) plugin introduced to rerun a set of steps on failure:
28
+
29
+ ```js
30
+ // editing in text in iframe
31
+ // if iframe was not loaded - retry 5 times
32
+ await retryTo(() => {
33
+ I.switchTo('#editor frame');
34
+ I.fillField('textarea', 'value');
35
+ }, 5);
36
+ ```
37
+
38
+ * [Playwright] added `locale` configuration
39
+ * [WebDriver] upgraded to webdriverio v7
40
+
41
+ 🐛 Bugfixes:
42
+
43
+ * Fixed allure plugin "Unexpected endStep()" error in #3098 by @abhimanyupandian
44
+ * [Puppeteer] always close remote browser on test end. See #3054 by @mattonem
45
+ * stepbyStepReport Plugin: Disabled screenshots after test has failed. See #3119 by @ioannisChalkias
46
+
47
+
48
+ ## 3.1.3
49
+
50
+ đŸ›Šī¸ Features:
51
+
52
+ * BDD Improvement. Added `DataTableArgument` class to work with table data structures.
53
+
54
+ ```js
55
+ const { DataTableArgument } = require('codeceptjs');
56
+ //...
57
+ Given('I have an employee card', (table) => {
58
+ const dataTableArgument = new DataTableArgument(table);
59
+ const hashes = dataTableArgument.hashes();
60
+ // hashes = [{ name: 'Harry', surname: 'Potter', position: 'Seeker' }];
61
+ const rows = dataTableArgument.rows();
62
+ // rows = [['Harry', 'Potter', Seeker]];
63
+ }
64
+ ```
65
+ See updated [BDD section](https://codecept.io/bdd/) for more API options. Thanks to @EgorBodnar
66
+
67
+ * Support `cjs` file extensions for config file: `codecept.conf.cjs`. See #3052 by @kalvenschraut
68
+ * API updates: Added `test.file` and `suite.file` properties to `test` and `suite` objects to use in helpers and plugins.
69
+
70
+ 🐛 Bugfixes:
71
+
72
+ * [Playwright] Fixed resetting `test.artifacts` for failing tests. See #3033 by @jancorvus. Fixes #3032
73
+ * [Playwright] Apply `basicAuth` credentials to all opened browser contexts. See #3036 by @nikocanvacom. Fixes #3035
74
+ * [WebDriver] Updated `webdriverio` default version to `^6.12.1`. See #3043 by @sridhareaswaran
75
+ * [Playwright] `I.haveRequestHeaders` affects all tabs. See #3049 by @jancorvus
76
+ * BDD: Fixed unhandled empty feature files. Fix #3046 by @abhimanyupandian
77
+ * Fixed `RangeError: Invalid string length` in `recorder.js` when running huge amount of tests.
78
+ * [Appium] Fixed definitions for `touchPerform`, `hideDeviceKeyboard`, `removeApp` by @mirao
79
+
80
+ 📖 Documentation:
81
+
82
+ * Added Testrail reporter [Reports Docs](https://codecept.io/reports/#testrail)
83
+
84
+
85
+ ## 3.1.2
86
+
87
+ đŸ›Šī¸ Features:
88
+
89
+ * Added `coverage` plugin to generate code coverage for Playwright & Puppeteer. By @anirudh-modi
90
+ * Added `subtitle` plugin to generate subtitles for videos recorded with Playwright. By @anirudh-modi
91
+ * Configuration: `config.tests` to accept array of file patterns. See #2994 by @monsteramba
92
+
93
+ ```js
94
+ exports.config = {
95
+ tests: ['./*_test.js','./sampleTest.js'],
96
+ // ...
97
+ }
98
+ ```
99
+ * Notification is shown for test files without `Feature()`. See #3011 by @PeterNgTr
100
+
101
+ 🐛 Bugfixes:
102
+
103
+ * [Playwright] Fixed #2986 error is thrown when deleting a missing video. Fix by @hatufacci
104
+ * Fixed false positive result when invalid function is called in a helper. See #2997 by @abhimanyupandian
105
+ * [Appium] Removed full page mode for `saveScreenshot`. See #3002 by @nlespiaucq
106
+ * [Playwright] Fixed #3003 saving trace for a test with a long name. Fix by @hatufacci
107
+
108
+ 🎱 Other:
109
+
110
+ * Deprecated `puppeteerCoverage` plugin in favor of `coverage` plugin.
111
+
112
+ ## 3.1.1
113
+
114
+ * [Appium] Fixed #2759
115
+ `grabNumberOfVisibleElements`, `grabAttributeFrom`, `grabAttributeFromAll` to allow id locators.
116
+
1
117
  ## 3.1.0
2
118
 
3
119
  * [Plawyright] Updated to Playwright 1.13
120
+ * [Playwright] **Possible breaking change**: `BrowserContext` is initialized before each test and closed after. This behavior matches recommendation from Playwright team to use different contexts for tests.
121
+ * [Puppeteer] Updated to Puppeteer 10.2.
122
+ * [Protractor] Helper deprecated
123
+
124
+ đŸ›Šī¸ Features:
125
+
4
126
  * [Playwright] Added recording of [video](https://codecept.io/playwright/#video) and [traces](https://codecept.io/playwright/#trace) by @davertmik
5
127
  * [Playwritght] [Mocking requests](https://codecept.io/playwright/#mocking-network-requests) implemented via `route` API of Playwright by @davertmik
6
128
  * [Playwright] Added **support for [React locators](https://codecept.io/react/#locators)** in #2912 by @AAAstorga
7
- * [Puppeteer] Updated to Puppeteer 10.2.
129
+
130
+ 🐛 Bugfixes:
131
+
8
132
  * [Puppeteer] Fixed #2244 `els[0]._clickablePoint is not a function` by @karunandrii.
9
133
  * [Puppeteer] Fixed `fillField` to check for invisible elements. See #2916 by @anne-open-xchange
10
134
  * [Playwright] Reset of dialog event listener before registration of new one. #2946 by @nikocanvacom
@@ -16,14 +140,16 @@
16
140
 
17
141
  ## 3.0.7
18
142
 
19
- Documentation fixes:
143
+ 📖 Documentation fixes:
144
+
20
145
  * Remove broken link from `Nightmare helper`. See #2860 by @Arhell
21
146
  * Fixed broken links in `playwright.md`. See #2848 by @johnhoodjr
22
147
  * Fix mocha-multi config example. See #2881 by @rimesc
23
148
  * Fix small errors in email documentation file. See #2884 by @mkrtchian
24
149
  * Improve documentation for `Sharing Data Between Workers` section. See #2891 by @ngraf
25
150
 
26
- Features:
151
+ đŸ›Šī¸ Features:
152
+
27
153
  * [WebDriver] Shadow DOM Support for `Webdriver`. See #2741 by @gkushang
28
154
  * [Release management] Introduce the versioning automatically, it follows the semantics versioning. See #2883 by @PeterNgTr
29
155
  * Adding opts into `Scenario.skip` that it would be useful for building reports. See #2867 by @AlexKo4
package/README.md CHANGED
@@ -29,7 +29,7 @@ Scenario('check Welcome page on site', ({ I }) => {
29
29
 
30
30
  CodeceptJS tests are:
31
31
 
32
- * **Synchronous**. You don't need to care about callbacks, or promises, test scenarios are linear, your test should be too.
32
+ * **Synchronous**. You don't need to care about callbacks or promises or test scenarios which are linear. But, your tests should be linear.
33
33
  * Written from **user's perspective**. Every action is a method of `I`. That makes test easy to read, write and maintain even for non-tech persons.
34
34
  * Backend **API agnostic**. We don't know which WebDriver implementation is running this test. We can easily switch from WebDriverIO to Protractor or PhantomJS.
35
35
 
@@ -38,11 +38,10 @@ CodeceptJS uses **Helper** modules to provide actions to `I` object. Currently C
38
38
  * [**Playwright**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Playwright.md) - is a Node library to automate the Chromium, WebKit and Firefox browsers with a single API.
39
39
  * [**Puppeteer**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Puppeteer.md) - uses Google Chrome's Puppeteer for fast headless testing.
40
40
  * [**WebDriver**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/WebDriver.md) - uses [webdriverio](http://webdriver.io/) to run tests via WebDriver protocol.
41
- * [**Protractor**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Protractor.md) - helper empowered by [Protractor](http://protractortest.org/) to run tests via WebDriver protocol.
42
41
  * [**TestCafe**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/TestCafe.md) - cheap and fast cross-browser test automation.
43
42
  * [**Nightmare**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Nightmare.md) - uses Electron and NightmareJS to run tests.
44
43
  * [**Appium**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Appium.md) - for **mobile testing** with Appium
45
- * [**Detox**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Detox.md) - This is a wrapper on top of Detox library, aimied to unify testing experience for CodeceptJS framework. Detox provides a grey box testing for mobile applications, playing especially good for React Native apps.
44
+ * [**Detox**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Detox.md) - This is a wrapper on top of Detox library, aimed to unify testing experience for CodeceptJS framework. Detox provides a grey box testing for mobile applications, playing especially well for React Native apps.
46
45
 
47
46
  And more to come...
48
47
 
package/bin/codecept.js CHANGED
@@ -105,6 +105,7 @@ program.command('run [test]')
105
105
  .option('-c, --config [file]', 'configuration file to be used')
106
106
  .option('--features', 'run only *.feature files and skip tests')
107
107
  .option('--tests', 'run only JS test files and skip features')
108
+ .option('--no-timeouts', 'disable all timeouts')
108
109
  .option('-p, --plugins <k=v,k2=v2,...>', 'enable plugins, comma-separated')
109
110
 
110
111
  // mocha options
package/docs/advanced.md CHANGED
@@ -100,7 +100,7 @@ Scenario('update user profile', ({ }) => {
100
100
  All tests with `@tag` could be executed with `--grep @tag` option.
101
101
 
102
102
  ```sh
103
- codeceptjs run --grep @slow
103
+ npx codeceptjs run --grep @slow
104
104
  ```
105
105
 
106
106
  Use regex for more flexible filtering:
@@ -119,24 +119,30 @@ CodeceptJS provides a debug mode in which additional information is printed.
119
119
  It can be turned on with `--debug` flag.
120
120
 
121
121
  ```sh
122
- codeceptjs run --debug
122
+ npx codeceptjs run --debug
123
123
  ```
124
124
 
125
125
  to receive even more information turn on `--verbose` flag:
126
126
 
127
127
  ```sh
128
- codeceptjs run --verbose
128
+ npx codeceptjs run --verbose
129
129
  ```
130
130
 
131
- And don't forget that you can pause execution and enter **interactive console** mode by calling `pause()` inside your test.
131
+ > You can pause execution and enter **interactive console** mode by calling `pause()` inside your test.
132
132
 
133
- For advanced debugging use NodeJS debugger. In WebStorm IDE:
133
+ To see a complete internal debug of CodeceptJS use `DEBUG` env variable:
134
+
135
+ ```sh
136
+ DEBUG=codeceptjs:* npx codeceptjs run
137
+ ```
138
+
139
+ For an interactive debugging use NodeJS debugger. In **WebStorm**:
134
140
 
135
141
  ```sh
136
142
  node $NODE_DEBUG_OPTION ./node_modules/.bin/codeceptjs run
137
143
  ```
138
144
 
139
- For Visual Studio Code, add the following configuration in launch.json:
145
+ For **Visual Studio Code**, add the following configuration in launch.json:
140
146
 
141
147
  ```json
142
148
  {
@@ -180,29 +186,99 @@ You can use this options for build your own [plugins](https://codecept.io/hooks/
180
186
  });
181
187
  ```
182
188
 
183
- ### Timeout
189
+ ### Timeout <Badge text="Updated in 3.2" type="warning"/>
184
190
 
185
- By default there is no timeout for tests, however you can change this value for a specific suite:
191
+ Tests can get stuck due to various reasons such as network connection issues, crashed browser, etc.
192
+ This can make tests process hang. To prevent these situations timeouts can be used. Timeouts can be set explicitly for flaky parts of code, or implicitly in a config.
193
+
194
+ > Previous timeout implementation was disabled as it had no effect when dealing with steps and promises.
195
+
196
+ ### Steps Timeout
197
+
198
+ It is possible to limit a step execution to specified time with `I.limitTime` command.
199
+ It will set timeout in seconds for the next executed step:
186
200
 
187
201
  ```js
188
- Feature('Stop me').timeout(5000); // set timeout to 5s
202
+ // limit clicking to 5 seconds
203
+ I.limitTime(5).click('Link')
189
204
  ```
190
205
 
191
- or for the test:
206
+ It is possible to set a timeout for all steps implicitly (except waiters) using [stepTimeout plugin](/plugins/#steptimeout).
207
+
208
+ ### Tests Timeout
209
+
210
+ Test timeout can be set in seconds via Scenario options:
192
211
 
193
212
  ```js
194
- // set timeout to 1s
195
- Scenario("Stop me faster",({ I }) => {
196
- // test goes here
197
- }).timeout(1000);
213
+ // limit test to 20 seconds
214
+ Scenario('slow test that should be stopped', { timeout: 20 }, ({ I }) => {
215
+ // ...
216
+ })
217
+ ```
198
218
 
199
- // alternative
200
- Scenario("Stop me faster", {timeout: 1000},({ I }) => {});
219
+ This timeout can be set globally in `codecept.conf.js` in seconds:
201
220
 
202
- // disable timeout for this scenario
203
- Scenario("Don't stop me", {timeout: 0},({ I }) => {});
221
+ ```js
222
+ exports.config = {
223
+
224
+ // each test must not run longer than 5 mins
225
+ timeout: 300,
226
+
227
+ }
204
228
  ```
205
229
 
230
+ ### Suites Timeout
231
+
232
+ A timeout for a group of tests can be set on Feature level via options.
233
+
234
+ ```js
235
+ // limit all tests in this suite to 30 seconds
236
+ Feature('flaky tests', { timeout: 30 })
237
+ ```
238
+
239
+ ### Sum Up
240
+
241
+ Let's list all available timeout options.
242
+
243
+ Timeouts can be set globally in config:
244
+
245
+ ```js
246
+ // in codecept.confg.js:
247
+ { // ...
248
+ timeout: 30, // limit all tests in all suites to 30 secs
249
+
250
+ plugins: {
251
+ stepTimeout: {
252
+ enabled: true,
253
+ timeout: 10, // limit all steps except waiters to 10 secs
254
+ }
255
+ }
256
+ }
257
+
258
+ ```
259
+
260
+ or inside a test file:
261
+
262
+ ```js
263
+ // limit all tests in this suite to 10 secs
264
+ Feature('tests with timeout', { timeout: 10 });
265
+
266
+ // limit this test to 20 secs
267
+ Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {
268
+ // limit step to 5 seconds
269
+ I.limitTime(5).click('Link');
270
+ });
271
+ ```
272
+
273
+ Global timeouts will be overridden by explicit timeouts of a test or steps.
274
+
275
+ ### Disable Timeouts
276
+
277
+ To execute tests ignoring all timeout settings use `--no-timeouts` option:
278
+
279
+ ```
280
+ npx codeceptjs run --no-timeouts
281
+ ```
206
282
 
207
283
  ## Dynamic Configuration
208
284
 
@@ -249,45 +325,3 @@ Please note that some config changes can't be applied on the fly. For instance,
249
325
 
250
326
  Configuration changes will be reverted after a test or a suite.
251
327
 
252
-
253
- ### Rerunning Flaky Tests Multiple Times <Badge text="Since 2.4" type="warning"/>
254
-
255
- End to end tests can be flaky for various reasons. Even when we can't do anything to solve this problem it we can do next two things:
256
-
257
- * Detect flaky tests in our suite
258
- * Fix flaky tests by rerunning them.
259
-
260
- Both tasks can be achieved with [`run-rerun` command](/commands/#run-rerun) which runs tests multiple times until all tests are passed.
261
-
262
- You should set min and max runs boundaries so when few tests fail in a row you can rerun them until they are succeeded.
263
-
264
- ```js
265
- // inside to codecept.conf.js
266
- exports.config = { // ...
267
- rerun: {
268
- // run 4 times until 1st success
269
- minSuccess: 1,
270
- maxReruns: 4,
271
- }
272
- }
273
- ```
274
-
275
- If you want to check all your tests for stability you can set high boundaries for minimal success:
276
-
277
- ```js
278
- // inside to codecept.conf.js
279
- exports.config = { // ...
280
- rerun: {
281
- // run all tests must pass exactly 5 times
282
- minSuccess: 5,
283
- maxReruns: 5,
284
- }
285
- }
286
- ```
287
-
288
- Now execute tests with `run-rerun` command:
289
-
290
- ```
291
- npx codeceptjs run-rerun
292
- ```
293
-
package/docs/basics.md CHANGED
@@ -108,7 +108,7 @@ I.seeElement({name: 'password'});
108
108
  I.seeElement({react: 'user-profile', props: {name: 'davert'}});
109
109
  ```
110
110
 
111
- In [mobile testing](http://codecept.io/mobile/#locating-elements) you can use `~` to specify the accessibility id to locate an element. In web application you can locate elements by their `aria-label` value.
111
+ In [mobile testing](https://codecept.io/mobile/#locating-elements) you can use `~` to specify the accessibility id to locate an element. In web application you can locate elements by their `aria-label` value.
112
112
 
113
113
  ```js
114
114
  // locate element by [aria-label] attribute in web
package/docs/bdd.md CHANGED
@@ -264,8 +264,10 @@ You can also use the `parse()` method to obtain an object that allow you to get
264
264
  - `raw()` - returns the table as a 2-D array
265
265
  - `rows()` - returns the table as a 2-D array, without the first row
266
266
  - `hashes()` - returns an array of objects where each row is converted to an object (column header is the key)
267
+ - `rowsHash()` - returns an object where each row corresponds to an entry(first column is the key, second column is the value)
268
+ - `transpose()` - transpose the data, returns nothing. To work with the transposed table use the methods above.
267
269
 
268
- If we use hashes() with the previous exemple :
270
+ If we use hashes() with the previous example :
269
271
 
270
272
  ```js
271
273
  Given('I have products in my cart', (table) => { // eslint-disable-line
@@ -281,7 +283,59 @@ Given('I have products in my cart', (table) => { // eslint-disable-line
281
283
  }
282
284
  });
283
285
  ```
286
+ Examples of tables using:
284
287
 
288
+ ```gherkin
289
+ Given I have a short employees card
290
+ | Harry | Potter |
291
+ | Chuck | Norris |
292
+ ```
293
+ ```js
294
+ const { DataTableArgument } = require('codeceptjs');
295
+ //...
296
+ Given('I have a short employees card', (table) => {
297
+ const dataTableArgument = new DataTableArgument(table);
298
+ const raw = dataTableArgument.raw();
299
+ // row = [['Harry', 'Potter'], ['Chuck', 'Norris']]
300
+ dataTableArgument.transpose();
301
+ const transposedRaw = dataTableArgument.raw();
302
+ // transposedRaw = [['Harry', 'Chuck'], ['Potter', 'Norris']];
303
+ }
304
+ );
305
+ ```
306
+ ```gherkin
307
+ Given I have an employee card
308
+ | name | surname | position |
309
+ | Harry | Potter | Seeker |
310
+ ```
311
+ ```js
312
+ const { DataTableArgument } = require('codeceptjs');
313
+ //...
314
+ Given('I have an employee card', (table) => {
315
+ const dataTableArgument = new DataTableArgument(table);
316
+ const hashes = dataTableArgument.hashes();
317
+ // hashes = [{ name: 'Harry', surname: 'Potter', position: 'Seeker' }];
318
+ const rows = dataTableArgument.rows();
319
+ // rows = [['Harry', 'Potter', Seeker]];
320
+ }
321
+ );
322
+ ```
323
+ ```gherkin
324
+ Given I have a formatted employee card
325
+ | name | Harry |
326
+ | surname | Potter |
327
+ | position | Seeker |
328
+ ```
329
+ ```js
330
+ const { DataTableArgument } = require('codeceptjs');
331
+ //...
332
+ Given('I have a formatted employee card', (table) => {
333
+ const dataTableArgument = new DataTableArgument(table);
334
+ const rawHash = dataTableArgument.rowsHash();
335
+ // rawHash = { name: 'Harry', surname: 'Potter', position: 'Seeker' };
336
+ }
337
+ );
338
+ ```
285
339
  ### Examples
286
340
 
287
341
  In case scenarios represent the same logic but differ on data, we can use *Scenario Outline* to provide different examples for the same behavior. Scenario outline is just like a basic scenario with some values replaced with placeholders, which are filled from a table. Each set of values is executed as a different test.