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.
- package/CHANGELOG.md +129 -3
- package/README.md +2 -3
- package/bin/codecept.js +1 -0
- package/docs/advanced.md +94 -60
- package/docs/basics.md +1 -1
- package/docs/bdd.md +55 -1
- package/docs/build/Appium.js +106 -34
- package/docs/build/FileSystem.js +1 -0
- package/docs/build/Nightmare.js +48 -48
- package/docs/build/Playwright.js +97 -94
- package/docs/build/Protractor.js +68 -81
- package/docs/build/Puppeteer.js +91 -93
- package/docs/build/REST.js +1 -0
- package/docs/build/TestCafe.js +44 -44
- package/docs/build/WebDriver.js +71 -95
- package/docs/changelog.md +144 -2
- package/docs/commands.md +21 -7
- package/docs/configuration.md +15 -2
- package/docs/custom-helpers.md +1 -36
- package/docs/helpers/Appium.md +97 -95
- package/docs/helpers/FileSystem.md +1 -1
- package/docs/helpers/Playwright.md +16 -18
- package/docs/helpers/Puppeteer.md +18 -18
- package/docs/helpers/REST.md +3 -1
- package/docs/helpers/WebDriver.md +3 -19
- package/docs/mobile-react-native-locators.md +3 -0
- package/docs/playwright.md +40 -0
- package/docs/plugins.md +185 -68
- package/docs/reports.md +23 -5
- package/lib/actor.js +20 -2
- package/lib/codecept.js +15 -2
- package/lib/command/info.js +1 -1
- package/lib/config.js +13 -1
- package/lib/container.js +3 -1
- package/lib/data/dataTableArgument.js +35 -0
- package/lib/helper/Appium.js +49 -4
- package/lib/helper/FileSystem.js +1 -0
- package/lib/helper/Playwright.js +35 -22
- package/lib/helper/Protractor.js +2 -14
- package/lib/helper/Puppeteer.js +20 -19
- package/lib/helper/REST.js +1 -0
- package/lib/helper/WebDriver.js +2 -16
- package/lib/index.js +2 -0
- package/lib/interfaces/featureConfig.js +3 -0
- package/lib/interfaces/gherkin.js +7 -1
- package/lib/interfaces/scenarioConfig.js +4 -0
- package/lib/listener/helpers.js +1 -0
- package/lib/listener/steps.js +21 -3
- package/lib/listener/timeout.js +71 -0
- package/lib/locator.js +3 -0
- package/lib/mochaFactory.js +13 -9
- package/lib/plugin/allure.js +6 -1
- package/lib/plugin/{puppeteerCoverage.js → coverage.js} +10 -22
- package/lib/plugin/customLocator.js +2 -2
- 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 +90 -0
- package/lib/plugin/subtitles.js +88 -0
- package/lib/plugin/tryTo.js +1 -1
- package/lib/recorder.js +21 -8
- package/lib/step.js +7 -2
- package/lib/store.js +2 -0
- package/lib/ui.js +2 -2
- package/package.json +6 -7
- package/typings/index.d.ts +8 -1
- package/typings/types.d.ts +198 -82
- 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
|
@@ -47,6 +47,7 @@ This helper should be configured in codecept.json or codecept.conf.js
|
|
|
47
47
|
- `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
48
48
|
- `windowSize`: (optional) default window size. Set a dimension like `640x480`.
|
|
49
49
|
- `userAgent`: (optional) user-agent string.
|
|
50
|
+
- `locale`: (optional) locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
|
|
50
51
|
- `manualStart`: - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
51
52
|
- `chromium`: (optional) pass additional chromium options
|
|
52
53
|
- `electron`: (optional) pass additional electron options
|
|
@@ -162,6 +163,19 @@ const { devices } = require('playwright');
|
|
|
162
163
|
}
|
|
163
164
|
```
|
|
164
165
|
|
|
166
|
+
#### Example #7: Launch test with a specifc user locale
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
{
|
|
170
|
+
helpers: {
|
|
171
|
+
Playwright : {
|
|
172
|
+
url: "http://localhost",
|
|
173
|
+
locale: "fr-FR",
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
165
179
|
Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
166
180
|
|
|
167
181
|
## Access From Helpers
|
|
@@ -1821,11 +1835,11 @@ I.waitForRequest(request => request.url() === 'http://example.com' && request.me
|
|
|
1821
1835
|
|
|
1822
1836
|
### waitForResponse
|
|
1823
1837
|
|
|
1824
|
-
Waits for a network
|
|
1838
|
+
Waits for a network response.
|
|
1825
1839
|
|
|
1826
1840
|
```js
|
|
1827
1841
|
I.waitForResponse('http://example.com/resource');
|
|
1828
|
-
I.waitForResponse(
|
|
1842
|
+
I.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
|
|
1829
1843
|
```
|
|
1830
1844
|
|
|
1831
1845
|
#### Parameters
|
|
@@ -1919,22 +1933,6 @@ I.waitToHide('#popup');
|
|
|
1919
1933
|
- `locator` **([string][9] | [object][7])** element located by CSS|XPath|strict locator.
|
|
1920
1934
|
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1921
1935
|
|
|
1922
|
-
### waitUntil
|
|
1923
|
-
|
|
1924
|
-
Waits for a function to return true (waits for 1sec by default).
|
|
1925
|
-
|
|
1926
|
-
```js
|
|
1927
|
-
I.waitUntil(() => window.requests == 0);
|
|
1928
|
-
I.waitUntil(() => window.requests == 0, 5);
|
|
1929
|
-
```
|
|
1930
|
-
|
|
1931
|
-
#### Parameters
|
|
1932
|
-
|
|
1933
|
-
- `fn` **([function][11] | [string][9])** function which is executed in browser context.
|
|
1934
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1935
|
-
- `timeoutMsg` **[string][9]** message to show in case of timeout fail.
|
|
1936
|
-
- `interval` **[number][10]?**
|
|
1937
|
-
|
|
1938
1936
|
### waitUrlEquals
|
|
1939
1937
|
|
|
1940
1938
|
Waits for the entire URL to match the expected
|
|
@@ -101,6 +101,8 @@ This helper should be configured in codecept.json or codecept.conf.js
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
> Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
105
|
+
|
|
104
106
|
#### Example #5: Target URL with provided basic authentication
|
|
105
107
|
|
|
106
108
|
```js
|
|
@@ -115,7 +117,21 @@ This helper should be configured in codecept.json or codecept.conf.js
|
|
|
115
117
|
}
|
|
116
118
|
```
|
|
117
119
|
|
|
118
|
-
|
|
120
|
+
#### Troubleshooting
|
|
121
|
+
|
|
122
|
+
Error Message: `No usable sandbox!`
|
|
123
|
+
|
|
124
|
+
When running Puppeteer on CI try to disable sandbox if you see that message
|
|
125
|
+
|
|
126
|
+
helpers: {
|
|
127
|
+
Puppeteer: {
|
|
128
|
+
url: 'http://localhost',
|
|
129
|
+
show: false,
|
|
130
|
+
chrome: {
|
|
131
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
}
|
|
119
135
|
|
|
120
136
|
## Access From Helpers
|
|
121
137
|
|
|
@@ -1598,7 +1614,7 @@ I.seeTitleEquals('Test title.');
|
|
|
1598
1614
|
|
|
1599
1615
|
#### Parameters
|
|
1600
1616
|
|
|
1601
|
-
- `text`
|
|
1617
|
+
- `text` **[string][8]** value to check.
|
|
1602
1618
|
|
|
1603
1619
|
### selectOption
|
|
1604
1620
|
|
|
@@ -1982,22 +1998,6 @@ I.waitToHide('#popup');
|
|
|
1982
1998
|
- `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
|
|
1983
1999
|
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1984
2000
|
|
|
1985
|
-
### waitUntil
|
|
1986
|
-
|
|
1987
|
-
Waits for a function to return true (waits for 1sec by default).
|
|
1988
|
-
|
|
1989
|
-
```js
|
|
1990
|
-
I.waitUntil(() => window.requests == 0);
|
|
1991
|
-
I.waitUntil(() => window.requests == 0, 5);
|
|
1992
|
-
```
|
|
1993
|
-
|
|
1994
|
-
#### Parameters
|
|
1995
|
-
|
|
1996
|
-
- `fn` **([function][12] | [string][8])** function which is executed in browser context.
|
|
1997
|
-
- `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
|
|
1998
|
-
- `timeoutMsg` **[string][8]** message to show in case of timeout fail.
|
|
1999
|
-
- `interval` **[number][10]?**
|
|
2000
|
-
|
|
2001
2001
|
### waitUrlEquals
|
|
2002
2002
|
|
|
2003
2003
|
Waits for the entire URL to match the expected
|
package/docs/helpers/REST.md
CHANGED
|
@@ -168,7 +168,7 @@ I.setRequestTimeout(10000); // In milliseconds
|
|
|
168
168
|
|
|
169
169
|
#### Parameters
|
|
170
170
|
|
|
171
|
-
- `newTimeout`
|
|
171
|
+
- `newTimeout` **[number][5]** timeout in milliseconds
|
|
172
172
|
|
|
173
173
|
[1]: https://github.com/axios/axios
|
|
174
174
|
|
|
@@ -177,3 +177,5 @@ I.setRequestTimeout(10000); // In milliseconds
|
|
|
177
177
|
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
178
178
|
|
|
179
179
|
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
180
|
+
|
|
181
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
@@ -599,7 +599,7 @@ I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
|
|
|
599
599
|
|
|
600
600
|
#### Parameters
|
|
601
601
|
|
|
602
|
-
- `timeouts` **
|
|
602
|
+
- `timeouts` **any** WebDriver timeouts object.
|
|
603
603
|
|
|
604
604
|
### dontSee
|
|
605
605
|
|
|
@@ -963,7 +963,7 @@ let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
|
963
963
|
- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator.
|
|
964
964
|
- `attr` **[string][19]** attribute name.
|
|
965
965
|
|
|
966
|
-
Returns **[Promise][25]<[string][19]>** attribute
|
|
966
|
+
Returns **[Promise][25]<[string][19]>** attribute value
|
|
967
967
|
|
|
968
968
|
### grabAttributeFromAll
|
|
969
969
|
|
|
@@ -979,7 +979,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
979
979
|
- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator.
|
|
980
980
|
- `attr` **[string][19]** attribute name.
|
|
981
981
|
|
|
982
|
-
Returns **[Promise][25]<[Array][27]<[string][19]>>** attribute
|
|
982
|
+
Returns **[Promise][25]<[Array][27]<[string][19]>>** attribute value
|
|
983
983
|
|
|
984
984
|
### grabBrowserLogs
|
|
985
985
|
|
|
@@ -2155,22 +2155,6 @@ I.waitToHide('#popup');
|
|
|
2155
2155
|
- `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator.
|
|
2156
2156
|
- `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
|
|
2157
2157
|
|
|
2158
|
-
### waitUntil
|
|
2159
|
-
|
|
2160
|
-
Waits for a function to return true (waits for 1sec by default).
|
|
2161
|
-
|
|
2162
|
-
```js
|
|
2163
|
-
I.waitUntil(() => window.requests == 0);
|
|
2164
|
-
I.waitUntil(() => window.requests == 0, 5);
|
|
2165
|
-
```
|
|
2166
|
-
|
|
2167
|
-
#### Parameters
|
|
2168
|
-
|
|
2169
|
-
- `fn` **([function][24] | [string][19])** function which is executed in browser context.
|
|
2170
|
-
- `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
|
|
2171
|
-
- `timeoutMsg` **[string][19]** message to show in case of timeout fail.
|
|
2172
|
-
- `interval` **[number][22]?**
|
|
2173
|
-
|
|
2174
2158
|
### waitUrlEquals
|
|
2175
2159
|
|
|
2176
2160
|
Waits for the entire URL to match the expected
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
## Automating React Native apps
|
|
2
2
|
|
|
3
3
|
### Problem
|
|
4
|
+
|
|
5
|
+
> ⚠️ **NOTE**: This problem is not actual starting from `react-native@0.65.x` [CHANGELOG](https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#android-specific-9), [#381fb3](https://github.com/facebook/react-native/commit/381fb395ad9d2d48717a5d082aaedbecdd804554)
|
|
6
|
+
|
|
4
7
|
Let's say we have a React Native app with component defined like this
|
|
5
8
|
```html
|
|
6
9
|
<Button testID='someButton'>My button</Button>
|
package/docs/playwright.md
CHANGED
|
@@ -406,6 +406,11 @@ When a test fails and video was enabled a video file is shown under the `artifac
|
|
|
406
406
|
|
|
407
407
|
Open video and use it to debug a failed test case. Video helps when running tests on CI. Configure your CI system to enable artifacts storage for `output/video` and review videos of failed test case to understand failures.
|
|
408
408
|
|
|
409
|
+
It is recommended to enable [subtitles](https://codecept.io/plugins/#subtitles) plugin which will generate subtitles from steps in `.srt` format. Subtitles file will be saved into after a video file so video player (like VLC) would load them automatically:
|
|
410
|
+
|
|
411
|
+

|
|
412
|
+
|
|
413
|
+
|
|
409
414
|
## Trace <Badge text="Since 3.1" type="warning"/>
|
|
410
415
|
|
|
411
416
|
If video is not enough to descover why a test failed a [trace](https://playwright.dev/docs/trace-viewer/) can be recorded.
|
|
@@ -456,6 +461,41 @@ For instance, this is how you can read a trace for a failed test from an example
|
|
|
456
461
|
npx playwright show-trace /home/davert/projects/codeceptjs/examples/output/trace/open.zip
|
|
457
462
|
```
|
|
458
463
|
|
|
464
|
+
## Capturing Code Coverage
|
|
465
|
+
|
|
466
|
+
Code coverage can be captured, by enabling the `coverage` plugin in `codecept.config.js`.
|
|
467
|
+
|
|
468
|
+
```js
|
|
469
|
+
{
|
|
470
|
+
plugins: {
|
|
471
|
+
coverage: {
|
|
472
|
+
enabled: true
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Once all the tests are completed, `codecept` will create and store coverage in `output/coverage` folder, as shown below.
|
|
479
|
+
|
|
480
|
+

|
|
481
|
+
|
|
482
|
+
Then you need to [convert code coverage from Playwright's format into Istanbul format](https://github.com/codeceptjs/CodeceptJS/wiki/Converting-Playwright-to-Istanbul-Coverage).
|
|
483
|
+
|
|
484
|
+
Once the istanbul compatible coverage is generated, use [`nyc`](https://www.npmjs.com/package/nyc) to generate your coverage report in your desired format.
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
npx nyc report --reporter html -t coverage
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
The above command will generate will generate coverage in an interactive html format. It should generate `html` files in the directory where your code coverage is present, something like shown below.
|
|
491
|
+
|
|
492
|
+

|
|
493
|
+
|
|
494
|
+
Open `index.html` in your browser to view the full interactive coverage report.
|
|
495
|
+
|
|
496
|
+

|
|
497
|
+
|
|
498
|
+

|
|
459
499
|
## Extending Helper
|
|
460
500
|
|
|
461
501
|
To create custom `I.*` commands using Playwright API you need to create a custom helper.
|
package/docs/plugins.md
CHANGED
|
@@ -409,6 +409,29 @@ Scenario('project update test', async (I) => {
|
|
|
409
409
|
|
|
410
410
|
- `config`
|
|
411
411
|
|
|
412
|
+
## coverage
|
|
413
|
+
|
|
414
|
+
Dumps code coverage from Playwright/Puppeteer after every test.
|
|
415
|
+
|
|
416
|
+
#### Configuration
|
|
417
|
+
|
|
418
|
+
```js
|
|
419
|
+
plugins: {
|
|
420
|
+
coverage: {
|
|
421
|
+
enabled: true
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Possible config options:
|
|
427
|
+
|
|
428
|
+
- `coverageDir`: directory to dump coverage files
|
|
429
|
+
- `uniqueFileName`: generate a unique filename by adding uuid
|
|
430
|
+
|
|
431
|
+
### Parameters
|
|
432
|
+
|
|
433
|
+
- `config`
|
|
434
|
+
|
|
412
435
|
## customLocator
|
|
413
436
|
|
|
414
437
|
Creates a [custom locator][3] by using special attributes in HTML.
|
|
@@ -441,7 +464,7 @@ Using `data-test` attribute with `$` prefix:
|
|
|
441
464
|
// in codecept.conf.js
|
|
442
465
|
plugins: {
|
|
443
466
|
customLocator: {
|
|
444
|
-
enabled: true
|
|
467
|
+
enabled: true,
|
|
445
468
|
attribute: 'data-test'
|
|
446
469
|
}
|
|
447
470
|
}
|
|
@@ -460,7 +483,7 @@ Using `data-qa` attribute with `=` prefix:
|
|
|
460
483
|
// in codecept.conf.js
|
|
461
484
|
plugins: {
|
|
462
485
|
customLocator: {
|
|
463
|
-
enabled: true
|
|
486
|
+
enabled: true,
|
|
464
487
|
prefix: '=',
|
|
465
488
|
attribute: 'data-qa'
|
|
466
489
|
}
|
|
@@ -536,45 +559,6 @@ Enable it manually on each run via `-p` option:
|
|
|
536
559
|
|
|
537
560
|
npx codeceptjs run -p pauseOnFail
|
|
538
561
|
|
|
539
|
-
## puppeteerCoverage
|
|
540
|
-
|
|
541
|
-
Dumps puppeteers code coverage after every test.
|
|
542
|
-
|
|
543
|
-
#### Configuration
|
|
544
|
-
|
|
545
|
-
Configuration can either be taken from a corresponding helper (deprecated) or a from plugin config (recommended).
|
|
546
|
-
|
|
547
|
-
```js
|
|
548
|
-
plugins: {
|
|
549
|
-
puppeteerCoverage: {
|
|
550
|
-
enabled: true
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
Possible config options:
|
|
556
|
-
|
|
557
|
-
- `coverageDir`: directory to dump coverage files
|
|
558
|
-
- `uniqueFileName`: generate a unique filename by adding uuid
|
|
559
|
-
|
|
560
|
-
First of all, your mileage may vary!
|
|
561
|
-
|
|
562
|
-
To work, you need the client javascript code to be NOT uglified. They need to be built in "development" mode.
|
|
563
|
-
And the end of your tests, you'll get a directory full of coverage per test run. Now what?
|
|
564
|
-
You'll need to convert the coverage code to something istanbul can read. Good news is someone wrote the code
|
|
565
|
-
for you (see puppeteer-to-istanbul link below). Then using istanbul you need to combine the converted
|
|
566
|
-
coverage and create a report. Good luck!
|
|
567
|
-
|
|
568
|
-
Links:
|
|
569
|
-
|
|
570
|
-
- [https://github.com/GoogleChrome/puppeteer/blob/v1.12.2/docs/api.md#class-coverage][7]
|
|
571
|
-
- [https://github.com/istanbuljs/puppeteer-to-istanbul][8]
|
|
572
|
-
- [https://github.com/gotwarlost/istanbul][9]
|
|
573
|
-
|
|
574
|
-
### Parameters
|
|
575
|
-
|
|
576
|
-
- `config`
|
|
577
|
-
|
|
578
562
|
## retryFailedStep
|
|
579
563
|
|
|
580
564
|
Retries each failed step in a test.
|
|
@@ -642,6 +626,75 @@ Scenario('scenario tite', () => {
|
|
|
642
626
|
|
|
643
627
|
- `config`
|
|
644
628
|
|
|
629
|
+
## retryTo
|
|
630
|
+
|
|
631
|
+
Adds global `retryTo` which retries steps a few times before failing.
|
|
632
|
+
|
|
633
|
+
Enable this plugin in `codecept.conf.js` (enabled by default for new setups):
|
|
634
|
+
|
|
635
|
+
```js
|
|
636
|
+
plugins: {
|
|
637
|
+
retryTo: {
|
|
638
|
+
enabled: true
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
Use it in your tests:
|
|
644
|
+
|
|
645
|
+
```js
|
|
646
|
+
// retry these steps 5 times before failing
|
|
647
|
+
await retryTo((tryNum) => {
|
|
648
|
+
I.switchTo('#editor frame');
|
|
649
|
+
I.click('Open');
|
|
650
|
+
I.see('Opened')
|
|
651
|
+
}, 5);
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
Set polling interval as 3rd argument (200ms by default):
|
|
655
|
+
|
|
656
|
+
```js
|
|
657
|
+
// retry these steps 5 times before failing
|
|
658
|
+
await retryTo((tryNum) => {
|
|
659
|
+
I.switchTo('#editor frame');
|
|
660
|
+
I.click('Open');
|
|
661
|
+
I.see('Opened')
|
|
662
|
+
}, 5, 100);
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
Default polling interval can be changed in a config:
|
|
666
|
+
|
|
667
|
+
```js
|
|
668
|
+
plugins: {
|
|
669
|
+
retryTo: {
|
|
670
|
+
enabled: true,
|
|
671
|
+
pollInterval: 500,
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
Disables retryFailedStep plugin for steps inside a block;
|
|
677
|
+
|
|
678
|
+
Use this plugin if:
|
|
679
|
+
|
|
680
|
+
- you need repeat a set of actions in flaky tests
|
|
681
|
+
- iframe was not rendered and you need to retry switching to it
|
|
682
|
+
|
|
683
|
+
#### Configuration
|
|
684
|
+
|
|
685
|
+
- `pollInterval` - default interval between retries in ms. 200 by default.
|
|
686
|
+
- `registerGlobal` - to register `retryTo` function globally, true by default
|
|
687
|
+
|
|
688
|
+
If `registerGlobal` is false you can use retryTo from the plugin:
|
|
689
|
+
|
|
690
|
+
```js
|
|
691
|
+
const retryTo = codeceptjs.container.plugins('retryTo');
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### Parameters
|
|
695
|
+
|
|
696
|
+
- `config`
|
|
697
|
+
|
|
645
698
|
## screenshotOnFail
|
|
646
699
|
|
|
647
700
|
Creates screenshot on failure. Screenshot is saved into `output` directory.
|
|
@@ -673,14 +726,14 @@ Possible config options:
|
|
|
673
726
|
|
|
674
727
|
## selenoid
|
|
675
728
|
|
|
676
|
-
[Selenoid][
|
|
729
|
+
[Selenoid][7] plugin automatically starts browsers and video recording.
|
|
677
730
|
Works with WebDriver helper.
|
|
678
731
|
|
|
679
732
|
### Prerequisite
|
|
680
733
|
|
|
681
734
|
This plugin **requires Docker** to be installed.
|
|
682
735
|
|
|
683
|
-
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][
|
|
736
|
+
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][8] tool from Selenoid
|
|
684
737
|
|
|
685
738
|
### Usage
|
|
686
739
|
|
|
@@ -709,7 +762,7 @@ plugins: {
|
|
|
709
762
|
}
|
|
710
763
|
```
|
|
711
764
|
|
|
712
|
-
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][
|
|
765
|
+
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][9] and start Selenoid automatically.
|
|
713
766
|
It will also create `browsers.json` file required by Selenoid.
|
|
714
767
|
|
|
715
768
|
In automatic mode the latest version of browser will be used for tests. It is recommended to specify exact version of each browser inside `browsers.json` file.
|
|
@@ -721,10 +774,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
|
|
|
721
774
|
While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
|
|
722
775
|
This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
|
|
723
776
|
|
|
724
|
-
> Use [Selenoid Configuration Manager][
|
|
777
|
+
> Use [Selenoid Configuration Manager][8] to create and start containers semi-automatically.
|
|
725
778
|
|
|
726
779
|
1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
|
|
727
|
-
[Refer to Selenoid documentation][
|
|
780
|
+
[Refer to Selenoid documentation][10] to know more about browsers.json.
|
|
728
781
|
|
|
729
782
|
_Sample browsers.json_
|
|
730
783
|
|
|
@@ -749,7 +802,7 @@ _Sample browsers.json_
|
|
|
749
802
|
|
|
750
803
|
2. Create Selenoid container
|
|
751
804
|
|
|
752
|
-
Run the following command to create a container. To know more [refer here][
|
|
805
|
+
Run the following command to create a container. To know more [refer here][11]
|
|
753
806
|
|
|
754
807
|
```bash
|
|
755
808
|
docker create \
|
|
@@ -782,7 +835,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
782
835
|
| enableVideo | Enable video recording and use `video` folder of output (default: false) |
|
|
783
836
|
| enableLog | Enable log recording and use `logs` folder of output (default: false) |
|
|
784
837
|
| deletePassed | Delete video and logs of passed tests (default : true) |
|
|
785
|
-
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][
|
|
838
|
+
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][12] to know more |
|
|
786
839
|
|
|
787
840
|
### Parameters
|
|
788
841
|
|
|
@@ -790,7 +843,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
790
843
|
|
|
791
844
|
## stepByStepReport
|
|
792
845
|
|
|
793
|
-
![step-by-step-report][
|
|
846
|
+
![step-by-step-report][13]
|
|
794
847
|
|
|
795
848
|
Generates step by step report for a test.
|
|
796
849
|
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
|
|
@@ -818,11 +871,81 @@ Possible config options:
|
|
|
818
871
|
- `fullPageScreenshots`: should full page screenshots be used. Default: false.
|
|
819
872
|
- `output`: a directory where reports should be stored. Default: `output`.
|
|
820
873
|
- `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false.
|
|
874
|
+
- \`disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true.
|
|
821
875
|
|
|
822
876
|
### Parameters
|
|
823
877
|
|
|
824
878
|
- `config` **any**
|
|
825
879
|
|
|
880
|
+
## stepTimeout
|
|
881
|
+
|
|
882
|
+
Set timeout for test steps globally.
|
|
883
|
+
|
|
884
|
+
Add this plugin to config file:
|
|
885
|
+
|
|
886
|
+
```js
|
|
887
|
+
plugins: {
|
|
888
|
+
stepTimeout: {
|
|
889
|
+
enabled: true
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
Run tests with plugin enabled:
|
|
895
|
+
|
|
896
|
+
npx codeceptjs run --plugins stepTimeout
|
|
897
|
+
|
|
898
|
+
#### Configuration:
|
|
899
|
+
|
|
900
|
+
- `timeout` - global step timeout, default 150 seconds
|
|
901
|
+
- `force` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false
|
|
902
|
+
- `noTimeoutSteps` - an array of steps with no timeout. Default:
|
|
903
|
+
|
|
904
|
+
- `amOnPage`
|
|
905
|
+
- `wait*`
|
|
906
|
+
|
|
907
|
+
you could set your own noTimeoutSteps which would replace the default one.
|
|
908
|
+
|
|
909
|
+
- `customTimeoutSteps` - an array of step actions with custom timeout. Use it to override or extend noTimeoutSteps.
|
|
910
|
+
You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`.
|
|
911
|
+
|
|
912
|
+
#### Example
|
|
913
|
+
|
|
914
|
+
```js
|
|
915
|
+
plugins: {
|
|
916
|
+
stepTimeout: {
|
|
917
|
+
enabled: true,
|
|
918
|
+
force: true,
|
|
919
|
+
noTimeoutSteps: [
|
|
920
|
+
'scroll*', // ignore all scroll steps
|
|
921
|
+
/Cookie/, // ignore all steps with a Cookie in it (by regexp)
|
|
922
|
+
],
|
|
923
|
+
customTimeoutSteps: [
|
|
924
|
+
['myFlakyStep*', 1],
|
|
925
|
+
['scrollWhichRequiresTimeout', 5],
|
|
926
|
+
]
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
### Parameters
|
|
932
|
+
|
|
933
|
+
- `config`
|
|
934
|
+
|
|
935
|
+
## subtitles
|
|
936
|
+
|
|
937
|
+
Automatically captures steps as subtitle, and saves it as an artifact when a video is found for a failed test
|
|
938
|
+
|
|
939
|
+
#### Configuration
|
|
940
|
+
|
|
941
|
+
```js
|
|
942
|
+
plugins: {
|
|
943
|
+
subtitles: {
|
|
944
|
+
enabled: true
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
```
|
|
948
|
+
|
|
826
949
|
## tryTo
|
|
827
950
|
|
|
828
951
|
Adds global `tryTo` function inside of which all failed steps won't fail a test but will return true/false.
|
|
@@ -897,7 +1020,7 @@ This plugin allows to run webdriverio services like:
|
|
|
897
1020
|
- browserstack
|
|
898
1021
|
- appium
|
|
899
1022
|
|
|
900
|
-
A complete list of all available services can be found on [webdriverio website][
|
|
1023
|
+
A complete list of all available services can be found on [webdriverio website][14].
|
|
901
1024
|
|
|
902
1025
|
#### Setup
|
|
903
1026
|
|
|
@@ -909,7 +1032,7 @@ See examples below:
|
|
|
909
1032
|
|
|
910
1033
|
#### Selenium Standalone Service
|
|
911
1034
|
|
|
912
|
-
Install `@wdio/selenium-standalone-service` package, as [described here][
|
|
1035
|
+
Install `@wdio/selenium-standalone-service` package, as [described here][15].
|
|
913
1036
|
It is important to make sure it is compatible with current webdriverio version.
|
|
914
1037
|
|
|
915
1038
|
Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
|
|
@@ -928,7 +1051,7 @@ Please note, this service can be used with Protractor helper as well!
|
|
|
928
1051
|
|
|
929
1052
|
#### Sauce Service
|
|
930
1053
|
|
|
931
|
-
Install `@wdio/sauce-service` package, as [described here][
|
|
1054
|
+
Install `@wdio/sauce-service` package, as [described here][16].
|
|
932
1055
|
It is important to make sure it is compatible with current webdriverio version.
|
|
933
1056
|
|
|
934
1057
|
Enable `wdio` plugin in plugins list and add `sauce` service:
|
|
@@ -970,28 +1093,22 @@ In the same manner additional services from webdriverio can be installed, enable
|
|
|
970
1093
|
|
|
971
1094
|
[6]: /basics/#pause
|
|
972
1095
|
|
|
973
|
-
[7]: https://
|
|
974
|
-
|
|
975
|
-
[8]: https://github.com/istanbuljs/puppeteer-to-istanbul
|
|
976
|
-
|
|
977
|
-
[9]: https://github.com/gotwarlost/istanbul
|
|
978
|
-
|
|
979
|
-
[10]: https://aerokube.com/selenoid/
|
|
1096
|
+
[7]: https://aerokube.com/selenoid/
|
|
980
1097
|
|
|
981
|
-
[
|
|
1098
|
+
[8]: https://aerokube.com/cm/latest/
|
|
982
1099
|
|
|
983
|
-
[
|
|
1100
|
+
[9]: https://hub.docker.com/u/selenoid
|
|
984
1101
|
|
|
985
|
-
[
|
|
1102
|
+
[10]: https://aerokube.com/selenoid/latest/#_prepare_configuration
|
|
986
1103
|
|
|
987
|
-
[
|
|
1104
|
+
[11]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
|
|
988
1105
|
|
|
989
|
-
[
|
|
1106
|
+
[12]: https://docs.docker.com/engine/reference/commandline/create/
|
|
990
1107
|
|
|
991
|
-
[
|
|
1108
|
+
[13]: https://codecept.io/img/codeceptjs-slideshow.gif
|
|
992
1109
|
|
|
993
|
-
[
|
|
1110
|
+
[14]: https://webdriver.io
|
|
994
1111
|
|
|
995
|
-
[
|
|
1112
|
+
[15]: https://webdriver.io/docs/selenium-standalone-service.html
|
|
996
1113
|
|
|
997
|
-
[
|
|
1114
|
+
[16]: https://webdriver.io/docs/sauce-service.html
|
package/docs/reports.md
CHANGED
|
@@ -7,8 +7,8 @@ title: Reporters
|
|
|
7
7
|
|
|
8
8
|
## Cli
|
|
9
9
|
|
|
10
|
-
By default CodeceptJS provides cli reporter with console output.
|
|
11
|
-
Test names and failures will be printed
|
|
10
|
+
By default, CodeceptJS provides cli reporter with console output.
|
|
11
|
+
Test names and failures will be printed out on screen.
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
GitHub --
|
|
@@ -33,8 +33,8 @@ GitHub --
|
|
|
33
33
|
Run with --verbose flag to see NodeJS stacktrace
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
output steps use `--steps` option:
|
|
38
38
|
```
|
|
39
39
|
npx codeceptjs run --steps
|
|
40
40
|
```
|
|
@@ -201,7 +201,7 @@ npx codeceptjs dry-run --debug -p allure
|
|
|
201
201
|
|
|
202
202
|
## ReportPortal
|
|
203
203
|
|
|
204
|
-
Allure is a great
|
|
204
|
+
Allure is a great reporting tool, however, if you are running tests on different machines it is hard to merge its XML result files to build a proper report. So, for enterprise grade reporting we recommend using [ReportPortal](https://reportportal.io).
|
|
205
205
|
|
|
206
206
|

|
|
207
207
|
|
|
@@ -376,3 +376,21 @@ npx codeceptjs run --reporter mocha-multi
|
|
|
376
376
|
```
|
|
377
377
|
|
|
378
378
|
This will give you cli with steps in console and HTML report in `output` directory.
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
## Testrail
|
|
382
|
+
|
|
383
|
+
Testrail integration with CodeceptJS is now so seamless. The test run is created automatically afterwards. The screenshots of failed tests are also attached to test results.
|
|
384
|
+
|
|
385
|
+
Try to use [codeceptjs-testrail](https://www.npmjs.com/package/codeceptjs-testrail) plugin
|
|
386
|
+
|
|
387
|
+
Install it via NPM:
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
npm i codeceptjs-testrail --save
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+

|
|
394
|
+
|
|
395
|
+
Now there is new feature, add the configuration to test run of test plan
|
|
396
|
+

|