codeceptjs 3.1.3 → 3.2.3
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.
- package/CHANGELOG.md +75 -1
- package/README.md +2 -3
- package/bin/codecept.js +1 -0
- package/docs/advanced.md +99 -61
- package/docs/basics.md +27 -2
- package/docs/bdd.md +2 -2
- package/docs/build/Appium.js +62 -0
- package/docs/build/FileSystem.js +12 -1
- package/docs/build/Playwright.js +37 -33
- package/docs/build/Protractor.js +9 -24
- package/docs/build/Puppeteer.js +10 -28
- package/docs/build/REST.js +1 -0
- package/docs/build/WebDriver.js +2 -24
- package/docs/changelog.md +75 -1
- package/docs/configuration.md +8 -8
- package/docs/custom-helpers.md +2 -37
- package/docs/data.md +9 -9
- package/docs/helpers/Appium.md +240 -198
- package/docs/helpers/FileSystem.md +12 -2
- package/docs/helpers/Playwright.md +226 -225
- package/docs/helpers/Puppeteer.md +1 -17
- package/docs/helpers/REST.md +3 -1
- package/docs/helpers/WebDriver.md +1 -17
- package/docs/installation.md +1 -1
- package/docs/mobile-react-native-locators.md +3 -0
- package/docs/mobile.md +11 -11
- package/docs/nightmare.md +3 -3
- package/docs/pageobjects.md +2 -0
- package/docs/playwright.md +4 -4
- package/docs/plugins.md +138 -9
- package/docs/puppeteer.md +5 -5
- package/docs/reports.md +3 -3
- package/docs/testcafe.md +1 -1
- package/docs/translation.md +1 -1
- package/docs/visual.md +2 -2
- package/docs/vue.md +1 -1
- package/docs/webdriver.md +2 -2
- package/lib/actor.js +19 -1
- package/lib/cli.js +25 -20
- package/lib/codecept.js +2 -0
- package/lib/command/info.js +1 -1
- package/lib/command/workers/runTests.js +25 -7
- package/lib/config.js +12 -0
- package/lib/container.js +3 -1
- package/lib/helper/Appium.js +62 -0
- package/lib/helper/FileSystem.js +12 -1
- package/lib/helper/Playwright.js +37 -23
- package/lib/helper/Protractor.js +2 -14
- package/lib/helper/Puppeteer.js +3 -18
- package/lib/helper/REST.js +1 -0
- package/lib/helper/WebDriver.js +2 -14
- package/lib/interfaces/featureConfig.js +3 -0
- package/lib/interfaces/scenarioConfig.js +4 -0
- package/lib/listener/steps.js +21 -3
- package/lib/listener/timeout.js +72 -0
- package/lib/locator.js +3 -0
- package/lib/plugin/allure.js +6 -1
- package/lib/plugin/autoLogin.js +1 -1
- package/lib/plugin/retryFailedStep.js +4 -3
- package/lib/plugin/retryTo.js +130 -0
- package/lib/plugin/screenshotOnFail.js +1 -0
- package/lib/plugin/stepByStepReport.js +7 -0
- package/lib/plugin/stepTimeout.js +91 -0
- package/lib/plugin/tryTo.js +6 -0
- package/lib/recorder.js +18 -6
- package/lib/step.js +58 -0
- package/lib/store.js +2 -0
- package/lib/ui.js +2 -2
- package/package.json +4 -6
- package/typings/index.d.ts +8 -1
- package/typings/types.d.ts +149 -164
- package/docs/angular.md +0 -325
- package/docs/helpers/Protractor.md +0 -1658
- package/docs/webapi/waitUntil.mustache +0 -11
- package/typings/Protractor.d.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
+
## 3.2.3
|
|
2
|
+
|
|
3
|
+
* Documentation improvements by @maojunxyz
|
|
4
|
+
* Guard mocha cli reporter from registering step logger multiple times #3180 by @nikocanvacom
|
|
5
|
+
* [Playwright] Fixed "tracing.stop: tracing.stop: ENAMETOOLONG: name too long" by @hatufacci
|
|
6
|
+
* Fixed #2889: return always the same error contract from simplifyTest. See #3168 by @andremoah
|
|
7
|
+
|
|
8
|
+
## 3.2.2
|
|
9
|
+
|
|
10
|
+
* [Playwright] Reverted removal of retry on context errors. Fixes #3130
|
|
11
|
+
* Timeout improvements by @nikocanvacom:
|
|
12
|
+
* Added priorites to timeouts
|
|
13
|
+
* Added `overrideStepLimits` to [stepTimeout plugin](https://codecept.io/plugins/#steptimeout) to override steps timeouts set by `limitTime`.
|
|
14
|
+
* Fixed step timeout not working due to override by NaN by test timeout #3126
|
|
15
|
+
* [Appium] Fixed logging error when `manualStart` is true. See #3140 by @nikocanvacom
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 3.2.1
|
|
19
|
+
|
|
20
|
+
> ♻️ This release fixes hanging of tests by reducing timeouts for automatic retries on failures.
|
|
21
|
+
|
|
22
|
+
* [retryFailedStep plugin] **New Defaults**: retries steps up to 3 times with factor of 1.5 (previously 5 with factor 2)
|
|
23
|
+
* [Playwright] - disabled retry on failed context actions (not needed anymore)
|
|
24
|
+
* [Puppeteer] - reduced retries on context failures to 3 times.
|
|
25
|
+
* [Playwright] Handling `crash` event to automatically close crashed pages.
|
|
26
|
+
|
|
27
|
+
## 3.2.0
|
|
28
|
+
|
|
29
|
+
🛩️ Features:
|
|
30
|
+
|
|
31
|
+
**[Timeouts](https://codecept.io/advanced/#timeout) implemented**
|
|
32
|
+
* global timeouts (via `timeout` config option).
|
|
33
|
+
* _Breaking change:_ timeout option expects **timeout in seconds**, not in milliseconds as it was previously.
|
|
34
|
+
* test timeouts (via `Scenario` and `Feature` options)
|
|
35
|
+
* _Breaking change:_ `Feature().timeout()` and `Scenario().timeout()` calls has no effect and are deprecated
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
// set timeout for every test in suite to 10 secs
|
|
39
|
+
Feature('tests with timeout', { timeout: 10 });
|
|
40
|
+
|
|
41
|
+
// set timeout for this test to 20 secs
|
|
42
|
+
Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
* step timeouts (See #3059 by @nikocanvacom)
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// set step timeout to 5 secs
|
|
49
|
+
I.limitTime(5).click('Link');
|
|
50
|
+
```
|
|
51
|
+
* `stepTimeout` plugin introduced to automatically add timeouts for each step (#3059 by @nikocanvacom).
|
|
52
|
+
|
|
53
|
+
[**retryTo**](/plugins/#retryto) plugin introduced to rerun a set of steps on failure:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
// editing in text in iframe
|
|
57
|
+
// if iframe was not loaded - retry 5 times
|
|
58
|
+
await retryTo(() => {
|
|
59
|
+
I.switchTo('#editor frame');
|
|
60
|
+
I.fillField('textarea', 'value');
|
|
61
|
+
}, 5);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
* [Playwright] added `locale` configuration
|
|
65
|
+
* [WebDriver] upgraded to webdriverio v7
|
|
66
|
+
|
|
67
|
+
🐛 Bugfixes:
|
|
68
|
+
|
|
69
|
+
* Fixed allure plugin "Unexpected endStep()" error in #3098 by @abhimanyupandian
|
|
70
|
+
* [Puppeteer] always close remote browser on test end. See #3054 by @mattonem
|
|
71
|
+
* stepbyStepReport Plugin: Disabled screenshots after test has failed. See #3119 by @ioannisChalkias
|
|
72
|
+
|
|
73
|
+
|
|
1
74
|
## 3.1.3
|
|
2
75
|
|
|
3
76
|
🛩️ Features:
|
|
@@ -15,7 +88,7 @@ Given('I have an employee card', (table) => {
|
|
|
15
88
|
// rows = [['Harry', 'Potter', Seeker]];
|
|
16
89
|
}
|
|
17
90
|
```
|
|
18
|
-
See updated [BDD section](https://codecept.io/bdd/) for more API options.
|
|
91
|
+
See updated [BDD section](https://codecept.io/bdd/) for more API options. Thanks to @EgorBodnar
|
|
19
92
|
|
|
20
93
|
* Support `cjs` file extensions for config file: `codecept.conf.cjs`. See #3052 by @kalvenschraut
|
|
21
94
|
* API updates: Added `test.file` and `suite.file` properties to `test` and `suite` objects to use in helpers and plugins.
|
|
@@ -28,6 +101,7 @@ See updated [BDD section](https://codecept.io/bdd/) for more API options.
|
|
|
28
101
|
* [Playwright] `I.haveRequestHeaders` affects all tabs. See #3049 by @jancorvus
|
|
29
102
|
* BDD: Fixed unhandled empty feature files. Fix #3046 by @abhimanyupandian
|
|
30
103
|
* Fixed `RangeError: Invalid string length` in `recorder.js` when running huge amount of tests.
|
|
104
|
+
* [Appium] Fixed definitions for `touchPerform`, `hideDeviceKeyboard`, `removeApp` by @mirao
|
|
31
105
|
|
|
32
106
|
📖 Documentation:
|
|
33
107
|
|
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
|
|
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,
|
|
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
|
@@ -97,10 +97,14 @@ Scenario('update user profile', ({ }) => {
|
|
|
97
97
|
}).tag('@slow').tag('important');
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
All tests with `@tag` could be executed with `--grep @tag` option.
|
|
100
|
+
All tests with `@tag` could be executed with `--grep '@tag'` option.
|
|
101
101
|
|
|
102
102
|
```sh
|
|
103
|
-
|
|
103
|
+
<<<<<<< HEAD
|
|
104
|
+
npx codeceptjs run --grep @slow
|
|
105
|
+
=======
|
|
106
|
+
codeceptjs run --grep '@slow'
|
|
107
|
+
>>>>>>> 435964dff7770cb3cd58c78a8579b6221a000d24
|
|
104
108
|
```
|
|
105
109
|
|
|
106
110
|
Use regex for more flexible filtering:
|
|
@@ -119,24 +123,30 @@ CodeceptJS provides a debug mode in which additional information is printed.
|
|
|
119
123
|
It can be turned on with `--debug` flag.
|
|
120
124
|
|
|
121
125
|
```sh
|
|
122
|
-
codeceptjs run --debug
|
|
126
|
+
npx codeceptjs run --debug
|
|
123
127
|
```
|
|
124
128
|
|
|
125
129
|
to receive even more information turn on `--verbose` flag:
|
|
126
130
|
|
|
127
131
|
```sh
|
|
128
|
-
codeceptjs run --verbose
|
|
132
|
+
npx codeceptjs run --verbose
|
|
129
133
|
```
|
|
130
134
|
|
|
131
|
-
|
|
135
|
+
> You can pause execution and enter **interactive console** mode by calling `pause()` inside your test.
|
|
132
136
|
|
|
133
|
-
|
|
137
|
+
To see a complete internal debug of CodeceptJS use `DEBUG` env variable:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
DEBUG=codeceptjs:* npx codeceptjs run
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
For an interactive debugging use NodeJS debugger. In **WebStorm**:
|
|
134
144
|
|
|
135
145
|
```sh
|
|
136
146
|
node $NODE_DEBUG_OPTION ./node_modules/.bin/codeceptjs run
|
|
137
147
|
```
|
|
138
148
|
|
|
139
|
-
For Visual Studio Code
|
|
149
|
+
For **Visual Studio Code**, add the following configuration in launch.json:
|
|
140
150
|
|
|
141
151
|
```json
|
|
142
152
|
{
|
|
@@ -180,29 +190,99 @@ You can use this options for build your own [plugins](https://codecept.io/hooks/
|
|
|
180
190
|
});
|
|
181
191
|
```
|
|
182
192
|
|
|
183
|
-
|
|
193
|
+
## Timeout <Badge text="Updated in 3.2" type="warning"/>
|
|
184
194
|
|
|
185
|
-
|
|
195
|
+
Tests can get stuck due to various reasons such as network connection issues, crashed browser, etc.
|
|
196
|
+
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.
|
|
197
|
+
|
|
198
|
+
> Previous timeout implementation was disabled as it had no effect when dealing with steps and promises.
|
|
199
|
+
|
|
200
|
+
### Steps Timeout
|
|
201
|
+
|
|
202
|
+
It is possible to limit a step execution to specified time with `I.limitTime` command.
|
|
203
|
+
It will set timeout in seconds for the next executed step:
|
|
186
204
|
|
|
187
205
|
```js
|
|
188
|
-
|
|
206
|
+
// limit clicking to 5 seconds
|
|
207
|
+
I.limitTime(5).click('Link')
|
|
189
208
|
```
|
|
190
209
|
|
|
191
|
-
|
|
210
|
+
It is possible to set a timeout for all steps implicitly (except waiters) using [stepTimeout plugin](/plugins/#steptimeout).
|
|
211
|
+
|
|
212
|
+
### Tests Timeout
|
|
213
|
+
|
|
214
|
+
Test timeout can be set in seconds via Scenario options:
|
|
192
215
|
|
|
193
216
|
```js
|
|
194
|
-
//
|
|
195
|
-
Scenario(
|
|
196
|
-
//
|
|
197
|
-
})
|
|
217
|
+
// limit test to 20 seconds
|
|
218
|
+
Scenario('slow test that should be stopped', { timeout: 20 }, ({ I }) => {
|
|
219
|
+
// ...
|
|
220
|
+
})
|
|
221
|
+
```
|
|
198
222
|
|
|
199
|
-
|
|
200
|
-
Scenario("Stop me faster", {timeout: 1000},({ I }) => {});
|
|
223
|
+
This timeout can be set globally in `codecept.conf.js` in seconds:
|
|
201
224
|
|
|
202
|
-
|
|
203
|
-
|
|
225
|
+
```js
|
|
226
|
+
exports.config = {
|
|
227
|
+
|
|
228
|
+
// each test must not run longer than 5 mins
|
|
229
|
+
timeout: 300,
|
|
230
|
+
|
|
231
|
+
}
|
|
204
232
|
```
|
|
205
233
|
|
|
234
|
+
### Suites Timeout
|
|
235
|
+
|
|
236
|
+
A timeout for a group of tests can be set on Feature level via options.
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
// limit all tests in this suite to 30 seconds
|
|
240
|
+
Feature('flaky tests', { timeout: 30 })
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Sum Up
|
|
244
|
+
|
|
245
|
+
Let's list all available timeout options.
|
|
246
|
+
|
|
247
|
+
Timeouts can be set globally in config:
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
// in codecept.confg.js:
|
|
251
|
+
{ // ...
|
|
252
|
+
timeout: 30, // limit all tests in all suites to 30 secs
|
|
253
|
+
|
|
254
|
+
plugins: {
|
|
255
|
+
stepTimeout: {
|
|
256
|
+
enabled: true,
|
|
257
|
+
timeout: 10, // limit all steps except waiters to 10 secs
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
or inside a test file:
|
|
265
|
+
|
|
266
|
+
```js
|
|
267
|
+
// limit all tests in this suite to 10 secs
|
|
268
|
+
Feature('tests with timeout', { timeout: 10 });
|
|
269
|
+
|
|
270
|
+
// limit this test to 20 secs
|
|
271
|
+
Scenario('a test with timeout', { timeout: 20 }, ({ I }) => {
|
|
272
|
+
// limit step to 5 seconds
|
|
273
|
+
I.limitTime(5).click('Link');
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Global timeouts will be overridden by explicit timeouts of a test or steps.
|
|
278
|
+
|
|
279
|
+
### Disable Timeouts
|
|
280
|
+
|
|
281
|
+
To execute tests ignoring all timeout settings use `--no-timeouts` option:
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
npx codeceptjs run --no-timeouts
|
|
285
|
+
```
|
|
206
286
|
|
|
207
287
|
## Dynamic Configuration
|
|
208
288
|
|
|
@@ -249,45 +329,3 @@ Please note that some config changes can't be applied on the fly. For instance,
|
|
|
249
329
|
|
|
250
330
|
Configuration changes will be reverted after a test or a suite.
|
|
251
331
|
|
|
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
|
@@ -41,7 +41,6 @@ Refer to following guides to more information on:
|
|
|
41
41
|
* [▶ Playwright](/playwright)
|
|
42
42
|
* [▶ WebDriver](/webdriver)
|
|
43
43
|
* [▶ Puppeteer](/puppeteer)
|
|
44
|
-
* [▶ Protractor](/angular)
|
|
45
44
|
* [▶ Nightmare](/nightmare)
|
|
46
45
|
* [▶ TestCafe](/testcafe)
|
|
47
46
|
|
|
@@ -108,7 +107,7 @@ I.seeElement({name: 'password'});
|
|
|
108
107
|
I.seeElement({react: 'user-profile', props: {name: 'davert'}});
|
|
109
108
|
```
|
|
110
109
|
|
|
111
|
-
In [mobile testing](
|
|
110
|
+
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
111
|
|
|
113
112
|
```js
|
|
114
113
|
// locate element by [aria-label] attribute in web
|
|
@@ -317,6 +316,32 @@ var assert = require('assert');
|
|
|
317
316
|
assert.equal(title, 'CodeceptJS');
|
|
318
317
|
```
|
|
319
318
|
|
|
319
|
+
It is important to understand the usage of **async** functions in CodeceptJS. While non-returning actions can be called without await, if an async function uses `grab*` action it must be called with `await`:
|
|
320
|
+
|
|
321
|
+
```js
|
|
322
|
+
// a helper function
|
|
323
|
+
async function getAllUsers(I) {
|
|
324
|
+
const users = await I.grabTextFrom('.users');
|
|
325
|
+
return users.filter(u => u.includes('active'))
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// a test
|
|
329
|
+
Scenario('try helper functions', async ({ I }) => {
|
|
330
|
+
// we call function with await because it includes `grab`
|
|
331
|
+
const users = await getAllUsers(I);
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
If you miss `await` you get commands unsynchrhonized. And this will result to an error like this:
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
(node:446390) UnhandledPromiseRejectionWarning: ...
|
|
339
|
+
at processTicksAndRejections (internal/process/task_queues.js:95:5)
|
|
340
|
+
(node:446390) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
If you face that error please make sure that all async functions are called with `await`.
|
|
344
|
+
|
|
320
345
|
## Running Tests
|
|
321
346
|
|
|
322
347
|
To launch tests use the `run` command, and to execute tests in [multiple browsers](/advanced/#multiple-browsers-execution) or [multiple threads](/advanced/#parallel-execution) use the `run-multiple` command.
|
package/docs/bdd.md
CHANGED
|
@@ -5,7 +5,7 @@ title: Behavior Driven Development
|
|
|
5
5
|
|
|
6
6
|
# Behavior Driven Development
|
|
7
7
|
|
|
8
|
-
Behavior Driven Development (BDD) is a popular software development methodology. BDD is considered an extension of TDD, and is greatly inspired by [Agile](
|
|
8
|
+
Behavior Driven Development (BDD) is a popular software development methodology. BDD is considered an extension of TDD, and is greatly inspired by [Agile](https://agilemanifesto.org/) practices. The primary reason to choose BDD as your development process is to break down communication barriers between business and technical teams. BDD encourages the use of automated testing to verify all documented features of a project from the very beginning. This is why it is common to talk about BDD in the context of test frameworks (like CodeceptJS). The BDD approach, however, is about much more than testing - it is a common language for all team members to use during the development process.
|
|
9
9
|
|
|
10
10
|
## What is Behavior Driven Development
|
|
11
11
|
|
|
@@ -55,7 +55,7 @@ I should see that total number of products I want to buy is 2
|
|
|
55
55
|
And my order amount is $1600
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
As we can see this simple story highlights core concepts that are called *contracts*. We should fulfill those contracts to model software correctly. But how we can verify that those contracts are being satisfied? [Cucumber](
|
|
58
|
+
As we can see this simple story highlights core concepts that are called *contracts*. We should fulfill those contracts to model software correctly. But how we can verify that those contracts are being satisfied? [Cucumber](https://cucumber.io) introduced a special language for such stories called **Gherkin**. Same story transformed to Gherkin will look like this:
|
|
59
59
|
|
|
60
60
|
```gherkin
|
|
61
61
|
Feature: checkout process
|