codeceptjs 3.0.7 → 3.1.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 +96 -2
- package/README.md +9 -1
- package/bin/codecept.js +27 -17
- package/docs/bdd.md +55 -1
- package/docs/build/Appium.js +76 -4
- package/docs/build/Playwright.js +186 -69
- package/docs/build/Protractor.js +2 -0
- package/docs/build/Puppeteer.js +56 -18
- package/docs/build/REST.js +12 -0
- package/docs/build/WebDriver.js +1 -3
- package/docs/changelog.md +96 -2
- package/docs/commands.md +21 -7
- package/docs/configuration.md +15 -2
- package/docs/helpers/Appium.md +96 -94
- package/docs/helpers/Playwright.md +259 -202
- package/docs/helpers/Puppeteer.md +17 -1
- package/docs/helpers/REST.md +23 -9
- package/docs/helpers/WebDriver.md +2 -2
- package/docs/mobile.md +2 -1
- package/docs/playwright.md +156 -6
- package/docs/plugins.md +61 -69
- package/docs/react.md +1 -1
- package/docs/reports.md +21 -3
- package/lib/actor.js +2 -3
- package/lib/codecept.js +13 -2
- package/lib/command/definitions.js +8 -1
- package/lib/command/run-multiple/collection.js +4 -0
- package/lib/config.js +1 -1
- package/lib/container.js +3 -3
- package/lib/data/dataTableArgument.js +35 -0
- package/lib/helper/Appium.js +49 -4
- package/lib/helper/Playwright.js +186 -69
- package/lib/helper/Protractor.js +2 -0
- package/lib/helper/Puppeteer.js +56 -18
- package/lib/helper/REST.js +12 -0
- package/lib/helper/WebDriver.js +1 -3
- package/lib/helper/errors/ConnectionRefused.js +1 -1
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +44 -32
- package/lib/index.js +2 -0
- package/lib/interfaces/gherkin.js +8 -1
- package/lib/listener/exit.js +2 -4
- package/lib/listener/helpers.js +4 -4
- package/lib/locator.js +7 -0
- package/lib/mochaFactory.js +13 -9
- package/lib/output.js +2 -2
- package/lib/plugin/allure.js +7 -18
- package/lib/plugin/commentStep.js +1 -1
- package/lib/plugin/{puppeteerCoverage.js → coverage.js} +10 -22
- package/lib/plugin/customLocator.js +2 -2
- package/lib/plugin/subtitles.js +88 -0
- package/lib/plugin/tryTo.js +1 -1
- package/lib/recorder.js +5 -3
- package/lib/step.js +4 -2
- package/package.json +4 -3
- package/typings/index.d.ts +2 -0
- package/typings/types.d.ts +158 -18
|
@@ -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
|
|
package/docs/helpers/REST.md
CHANGED
|
@@ -61,6 +61,8 @@ Executes axios request
|
|
|
61
61
|
|
|
62
62
|
- `request` **any**
|
|
63
63
|
|
|
64
|
+
Returns **[Promise][2]<any>** response
|
|
65
|
+
|
|
64
66
|
### _url
|
|
65
67
|
|
|
66
68
|
Generates url based on format sent (takes endpoint + url if latter lacks 'http')
|
|
@@ -80,7 +82,9 @@ I.sendDeleteRequest('/api/users/1');
|
|
|
80
82
|
#### Parameters
|
|
81
83
|
|
|
82
84
|
- `url` **any**
|
|
83
|
-
- `headers` **[object][
|
|
85
|
+
- `headers` **[object][3]** the headers object to be sent. By default it is sent as an empty object
|
|
86
|
+
|
|
87
|
+
Returns **[Promise][2]<any>** response
|
|
84
88
|
|
|
85
89
|
### sendGetRequest
|
|
86
90
|
|
|
@@ -93,7 +97,9 @@ I.sendGetRequest('/api/users.json');
|
|
|
93
97
|
#### Parameters
|
|
94
98
|
|
|
95
99
|
- `url` **any**
|
|
96
|
-
- `headers` **[object][
|
|
100
|
+
- `headers` **[object][3]** the headers object to be sent. By default it is sent as an empty object
|
|
101
|
+
|
|
102
|
+
Returns **[Promise][2]<any>** response
|
|
97
103
|
|
|
98
104
|
### sendPatchRequest
|
|
99
105
|
|
|
@@ -108,9 +114,11 @@ I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
|
108
114
|
|
|
109
115
|
#### Parameters
|
|
110
116
|
|
|
111
|
-
- `url` **[string][
|
|
117
|
+
- `url` **[string][4]**
|
|
112
118
|
- `payload` **any** the payload to be sent. By default it is sent as an empty object
|
|
113
|
-
- `headers` **[object][
|
|
119
|
+
- `headers` **[object][3]** the headers object to be sent. By default it is sent as an empty object
|
|
120
|
+
|
|
121
|
+
Returns **[Promise][2]<any>** response
|
|
114
122
|
|
|
115
123
|
### sendPostRequest
|
|
116
124
|
|
|
@@ -127,7 +135,9 @@ I.sendPostRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
|
127
135
|
|
|
128
136
|
- `url` **any**
|
|
129
137
|
- `payload` **any** the payload to be sent. By default it is sent as an empty object
|
|
130
|
-
- `headers` **[object][
|
|
138
|
+
- `headers` **[object][3]** the headers object to be sent. By default it is sent as an empty object
|
|
139
|
+
|
|
140
|
+
Returns **[Promise][2]<any>** response
|
|
131
141
|
|
|
132
142
|
### sendPutRequest
|
|
133
143
|
|
|
@@ -142,9 +152,11 @@ I.sendPutRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
|
142
152
|
|
|
143
153
|
#### Parameters
|
|
144
154
|
|
|
145
|
-
- `url` **[string][
|
|
155
|
+
- `url` **[string][4]**
|
|
146
156
|
- `payload` **any** the payload to be sent. By default it is sent as an empty object
|
|
147
|
-
- `headers` **[object][
|
|
157
|
+
- `headers` **[object][3]** the headers object to be sent. By default it is sent as an empty object
|
|
158
|
+
|
|
159
|
+
Returns **[Promise][2]<any>** response
|
|
148
160
|
|
|
149
161
|
### setRequestTimeout
|
|
150
162
|
|
|
@@ -160,6 +172,8 @@ I.setRequestTimeout(10000); // In milliseconds
|
|
|
160
172
|
|
|
161
173
|
[1]: https://github.com/axios/axios
|
|
162
174
|
|
|
163
|
-
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
175
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
176
|
+
|
|
177
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
164
178
|
|
|
165
|
-
[
|
|
179
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
@@ -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
|
|
package/docs/mobile.md
CHANGED
|
@@ -114,7 +114,7 @@ If you wish to use BrowserStack's [Automated Mobile App Testing](https://www.bro
|
|
|
114
114
|
|
|
115
115
|
```js
|
|
116
116
|
helpers: {
|
|
117
|
-
Appium:
|
|
117
|
+
Appium: {
|
|
118
118
|
app: "bs://<hashed app-id>",
|
|
119
119
|
host: "hub-cloud.browserstack.com",
|
|
120
120
|
port: 4444,
|
|
@@ -122,6 +122,7 @@ helpers: {
|
|
|
122
122
|
user: "BROWSERSTACK_USER",
|
|
123
123
|
key: "BROWSERSTACK_KEY",
|
|
124
124
|
device: "iPhone 7"
|
|
125
|
+
}
|
|
125
126
|
}
|
|
126
127
|
```
|
|
127
128
|
Here is the full list of [capabilities](https://www.browserstack.com/app-automate/capabilities).
|
package/docs/playwright.md
CHANGED
|
@@ -3,7 +3,7 @@ permalink: /playwright
|
|
|
3
3
|
title: Testing with Playwright
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Testing with Playwright
|
|
6
|
+
# Testing with Playwright
|
|
7
7
|
|
|
8
8
|
Playwright is a Node library to automate the [Chromium](https://www.chromium.org/Home), [WebKit](https://webkit.org/) and [Firefox](https://www.mozilla.org/en-US/firefox/new/) browsers as well as [Electron](https://www.electronjs.org/) apps with a single API. It enables **cross-browser** web automation that is **ever-green**, **capable**, **reliable** and **fast**.
|
|
9
9
|
|
|
@@ -322,30 +322,180 @@ Playwright can be added to GitHub Actions using [official action](https://github
|
|
|
322
322
|
|
|
323
323
|
## Accessing Playwright API
|
|
324
324
|
|
|
325
|
-
To get [Playwright API](https://
|
|
325
|
+
To get [Playwright API](https://playwright.dev/docs/api/class-playwright) inside a test use `I.usePlaywrightTo` method with a callback.
|
|
326
|
+
|
|
327
|
+
`usePlaywrightTo` passes in an instance of Playwright helper from which you can obtain access to main Playwright classes:
|
|
328
|
+
|
|
329
|
+
* [`browser`](https://playwright.dev/docs/api/class-browser)
|
|
330
|
+
* [`browserContext`](https://playwright.dev/docs/api/class-browsercontext)
|
|
331
|
+
* [`page`](https://playwright.dev/docs/api/class-page)
|
|
332
|
+
|
|
326
333
|
To keep test readable provide a description of a callback inside the first parameter.
|
|
327
334
|
|
|
328
335
|
```js
|
|
329
|
-
I.usePlaywrightTo('emulate offline mode', async ({ browser,
|
|
336
|
+
I.usePlaywrightTo('emulate offline mode', async ({ browser, browserContext, page }) => {
|
|
330
337
|
// use browser, page, context objects inside this function
|
|
331
|
-
await
|
|
338
|
+
await browserContext.setOffline(true);
|
|
332
339
|
});
|
|
333
340
|
```
|
|
334
341
|
|
|
335
342
|
Playwright commands are asynchronous so a callback function must be async.
|
|
336
343
|
|
|
337
|
-
A Playwright helper is passed as argument for callback, so you can combine
|
|
344
|
+
A Playwright helper is passed as argument for callback, so you can combine Playwright API with CodeceptJS API:
|
|
338
345
|
|
|
339
346
|
```js
|
|
340
347
|
I.usePlaywrightTo('emulate offline mode', async (Playwright) => {
|
|
341
348
|
// access internal objects browser, page, context of helper
|
|
342
|
-
await Playwright.
|
|
349
|
+
await Playwright.browserContext.setOffline(true);
|
|
343
350
|
// call a method of helper, await is required here
|
|
344
351
|
await Playwright.click('Reload');
|
|
345
352
|
});
|
|
346
353
|
|
|
347
354
|
```
|
|
348
355
|
|
|
356
|
+
## Mocking Network Requests <Badge text="Since 3.1" type="warning"/>
|
|
357
|
+
|
|
358
|
+
Network requests & responses can be mocked and modified. Use `mockRequest` which strictly follows [Playwright's `route` API](https://playwright.dev/docs/api/class-browsercontext#browser-context-route).
|
|
359
|
+
|
|
360
|
+
```js
|
|
361
|
+
I.mockRoute('/api/**', route => {
|
|
362
|
+
if (route.request().postData().includes('my-string'))
|
|
363
|
+
route.fulfill({ body: 'mocked-data' });
|
|
364
|
+
else
|
|
365
|
+
route.continue();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
I.mockRoute('**/*.{png,jpg,jpeg}', route => route.abort());
|
|
369
|
+
|
|
370
|
+
// To disable mocking for a route call `stopMockingRoute`
|
|
371
|
+
// for previously mocked URL
|
|
372
|
+
I.stopMockingRoute('**/*.{png,jpg,jpeg}'
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
To master request intercepting [use `route` object](https://playwright.dev/docs/api/class-route) object passed into mock request handler.
|
|
376
|
+
|
|
377
|
+
## Video <Badge text="Since 3.1" type="warning"/>
|
|
378
|
+
|
|
379
|
+
Playwright may record videos for failed tests. This can be enabled in a config with `video: true` option:
|
|
380
|
+
|
|
381
|
+
```js
|
|
382
|
+
exports.config = {
|
|
383
|
+
helpers: {
|
|
384
|
+
Playwright: {
|
|
385
|
+
// ...
|
|
386
|
+
video: true
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
When a test fails and video was enabled a video file is shown under the `artifacts` section in the error message:
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
-- FAILURES:
|
|
395
|
+
|
|
396
|
+
1) GitHub
|
|
397
|
+
open:
|
|
398
|
+
|
|
399
|
+
Scenario Steps:
|
|
400
|
+
- I.amOnPage("https://gothub11.com/search") at Test.<anonymous> (./github_test.js:16:5)
|
|
401
|
+
|
|
402
|
+
Artifacts:
|
|
403
|
+
- screenshot: /home/davert/projects/codeceptjs/examples/output/open.failed.png
|
|
404
|
+
- video: /home/davert/projects/codeceptjs/examples/output/videos/5ecf6aaa78865bce14d271b55de964fd.webm
|
|
405
|
+
```
|
|
406
|
+
|
|
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
|
+
|
|
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
|
+
|
|
414
|
+
## Trace <Badge text="Since 3.1" type="warning"/>
|
|
415
|
+
|
|
416
|
+
If video is not enough to descover why a test failed a [trace](https://playwright.dev/docs/trace-viewer/) can be recorded.
|
|
417
|
+
|
|
418
|
+

|
|
419
|
+
|
|
420
|
+
Inside a trace you get screenshots, DOM snapshots, console logs, network requests and playwright commands logged and showed on a timeline. This may help for a deep debug of a failed test cases. Trace file is saved into ZIP archive and can be viewed with Trace Viewer built into Playwright.
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
Enable trace with `trace: true` option in a config:
|
|
424
|
+
|
|
425
|
+
```js
|
|
426
|
+
exports.config = {
|
|
427
|
+
helpers: {
|
|
428
|
+
Playwright: {
|
|
429
|
+
// ...
|
|
430
|
+
trace: true
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
When a test fails and trace was enabled, a trace file is shown under the `artifacts` section in the error message:
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
-- FAILURES:
|
|
440
|
+
|
|
441
|
+
1) GitHub
|
|
442
|
+
open:
|
|
443
|
+
|
|
444
|
+
Scenario Steps:
|
|
445
|
+
- I.amOnPage("https://gothub11.com/search") at Test.<anonymous> (./github_test.js:16:5)
|
|
446
|
+
|
|
447
|
+
Artifacts:
|
|
448
|
+
- screenshot: /home/davert/projects/codeceptjs/examples/output/open.failed.png
|
|
449
|
+
- trace: /home/davert/projects/codeceptjs/examples/output/trace/open.zip
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
Use Playwright's trace viewer to analyze the trace:
|
|
453
|
+
|
|
454
|
+
```
|
|
455
|
+
npx playwright show-trace {path-to-trace-file}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
For instance, this is how you can read a trace for a failed test from an example:
|
|
459
|
+
|
|
460
|
+
```
|
|
461
|
+
npx playwright show-trace /home/davert/projects/codeceptjs/examples/output/trace/open.zip
|
|
462
|
+
```
|
|
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
|
+

|
|
349
499
|
## Extending Helper
|
|
350
500
|
|
|
351
501
|
To create custom `I.*` commands using Playwright API you need to create a custom helper.
|
package/docs/plugins.md
CHANGED
|
@@ -341,7 +341,7 @@ This plugin can be used
|
|
|
341
341
|
### Config
|
|
342
342
|
|
|
343
343
|
- `enabled` - (default: false) enable a plugin
|
|
344
|
-
- `
|
|
344
|
+
- `registerGlobal` - (default: false) register `__` template literal function globally. You can override function global name by providing a name as a value.
|
|
345
345
|
|
|
346
346
|
### Examples
|
|
347
347
|
|
|
@@ -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.
|
|
@@ -673,14 +657,14 @@ Possible config options:
|
|
|
673
657
|
|
|
674
658
|
## selenoid
|
|
675
659
|
|
|
676
|
-
[Selenoid][
|
|
660
|
+
[Selenoid][7] plugin automatically starts browsers and video recording.
|
|
677
661
|
Works with WebDriver helper.
|
|
678
662
|
|
|
679
663
|
### Prerequisite
|
|
680
664
|
|
|
681
665
|
This plugin **requires Docker** to be installed.
|
|
682
666
|
|
|
683
|
-
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][
|
|
667
|
+
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][8] tool from Selenoid
|
|
684
668
|
|
|
685
669
|
### Usage
|
|
686
670
|
|
|
@@ -709,7 +693,7 @@ plugins: {
|
|
|
709
693
|
}
|
|
710
694
|
```
|
|
711
695
|
|
|
712
|
-
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][
|
|
696
|
+
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][9] and start Selenoid automatically.
|
|
713
697
|
It will also create `browsers.json` file required by Selenoid.
|
|
714
698
|
|
|
715
699
|
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 +705,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
|
|
|
721
705
|
While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
|
|
722
706
|
This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
|
|
723
707
|
|
|
724
|
-
> Use [Selenoid Configuration Manager][
|
|
708
|
+
> Use [Selenoid Configuration Manager][8] to create and start containers semi-automatically.
|
|
725
709
|
|
|
726
710
|
1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
|
|
727
|
-
[Refer to Selenoid documentation][
|
|
711
|
+
[Refer to Selenoid documentation][10] to know more about browsers.json.
|
|
728
712
|
|
|
729
713
|
_Sample browsers.json_
|
|
730
714
|
|
|
@@ -749,7 +733,7 @@ _Sample browsers.json_
|
|
|
749
733
|
|
|
750
734
|
2. Create Selenoid container
|
|
751
735
|
|
|
752
|
-
Run the following command to create a container. To know more [refer here][
|
|
736
|
+
Run the following command to create a container. To know more [refer here][11]
|
|
753
737
|
|
|
754
738
|
```bash
|
|
755
739
|
docker create \
|
|
@@ -782,7 +766,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
782
766
|
| enableVideo | Enable video recording and use `video` folder of output (default: false) |
|
|
783
767
|
| enableLog | Enable log recording and use `logs` folder of output (default: false) |
|
|
784
768
|
| deletePassed | Delete video and logs of passed tests (default : true) |
|
|
785
|
-
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][
|
|
769
|
+
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][12] to know more |
|
|
786
770
|
|
|
787
771
|
### Parameters
|
|
788
772
|
|
|
@@ -790,7 +774,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
790
774
|
|
|
791
775
|
## stepByStepReport
|
|
792
776
|
|
|
793
|
-
![step-by-step-report][
|
|
777
|
+
![step-by-step-report][13]
|
|
794
778
|
|
|
795
779
|
Generates step by step report for a test.
|
|
796
780
|
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
|
|
@@ -823,6 +807,20 @@ Possible config options:
|
|
|
823
807
|
|
|
824
808
|
- `config` **any**
|
|
825
809
|
|
|
810
|
+
## subtitles
|
|
811
|
+
|
|
812
|
+
Automatically captures steps as subtitle, and saves it as an artifact when a video is found for a failed test
|
|
813
|
+
|
|
814
|
+
#### Configuration
|
|
815
|
+
|
|
816
|
+
```js
|
|
817
|
+
plugins: {
|
|
818
|
+
subtitles: {
|
|
819
|
+
enabled: true
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
```
|
|
823
|
+
|
|
826
824
|
## tryTo
|
|
827
825
|
|
|
828
826
|
Adds global `tryTo` function inside of which all failed steps won't fail a test but will return true/false.
|
|
@@ -897,7 +895,7 @@ This plugin allows to run webdriverio services like:
|
|
|
897
895
|
- browserstack
|
|
898
896
|
- appium
|
|
899
897
|
|
|
900
|
-
A complete list of all available services can be found on [webdriverio website][
|
|
898
|
+
A complete list of all available services can be found on [webdriverio website][14].
|
|
901
899
|
|
|
902
900
|
#### Setup
|
|
903
901
|
|
|
@@ -909,7 +907,7 @@ See examples below:
|
|
|
909
907
|
|
|
910
908
|
#### Selenium Standalone Service
|
|
911
909
|
|
|
912
|
-
Install `@wdio/selenium-standalone-service` package, as [described here][
|
|
910
|
+
Install `@wdio/selenium-standalone-service` package, as [described here][15].
|
|
913
911
|
It is important to make sure it is compatible with current webdriverio version.
|
|
914
912
|
|
|
915
913
|
Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
|
|
@@ -928,7 +926,7 @@ Please note, this service can be used with Protractor helper as well!
|
|
|
928
926
|
|
|
929
927
|
#### Sauce Service
|
|
930
928
|
|
|
931
|
-
Install `@wdio/sauce-service` package, as [described here][
|
|
929
|
+
Install `@wdio/sauce-service` package, as [described here][16].
|
|
932
930
|
It is important to make sure it is compatible with current webdriverio version.
|
|
933
931
|
|
|
934
932
|
Enable `wdio` plugin in plugins list and add `sauce` service:
|
|
@@ -970,28 +968,22 @@ In the same manner additional services from webdriverio can be installed, enable
|
|
|
970
968
|
|
|
971
969
|
[6]: /basics/#pause
|
|
972
970
|
|
|
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/
|
|
971
|
+
[7]: https://aerokube.com/selenoid/
|
|
980
972
|
|
|
981
|
-
[
|
|
973
|
+
[8]: https://aerokube.com/cm/latest/
|
|
982
974
|
|
|
983
|
-
[
|
|
975
|
+
[9]: https://hub.docker.com/u/selenoid
|
|
984
976
|
|
|
985
|
-
[
|
|
977
|
+
[10]: https://aerokube.com/selenoid/latest/#_prepare_configuration
|
|
986
978
|
|
|
987
|
-
[
|
|
979
|
+
[11]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
|
|
988
980
|
|
|
989
|
-
[
|
|
981
|
+
[12]: https://docs.docker.com/engine/reference/commandline/create/
|
|
990
982
|
|
|
991
|
-
[
|
|
983
|
+
[13]: https://codecept.io/img/codeceptjs-slideshow.gif
|
|
992
984
|
|
|
993
|
-
[
|
|
985
|
+
[14]: https://webdriver.io
|
|
994
986
|
|
|
995
|
-
[
|
|
987
|
+
[15]: https://webdriver.io/docs/selenium-standalone-service.html
|
|
996
988
|
|
|
997
|
-
[
|
|
989
|
+
[16]: https://webdriver.io/docs/sauce-service.html
|
package/docs/react.md
CHANGED
|
@@ -55,7 +55,7 @@ For React apps a special `react` locator is available. It allows to select an el
|
|
|
55
55
|
{ react: 'Input', state: 'valid'}
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
In WebDriver and
|
|
58
|
+
In WebDriver, Puppeteer, and Playwright you can use React locators in any method where locator is required:
|
|
59
59
|
|
|
60
60
|
```js
|
|
61
61
|
I.click({ react: 'Tab', props: { title: 'Click Me!' }});
|
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 --
|
|
@@ -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
|
+

|
package/lib/actor.js
CHANGED
|
@@ -28,7 +28,7 @@ class Actor {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @function
|
|
31
|
-
* @param {*} opts
|
|
31
|
+
* @param {*} [opts]
|
|
32
32
|
* @return {this}
|
|
33
33
|
* @inner
|
|
34
34
|
*/
|
|
@@ -74,8 +74,7 @@ module.exports = function (obj = {}) {
|
|
|
74
74
|
const helpers = container.helpers();
|
|
75
75
|
|
|
76
76
|
// add methods from enabled helpers
|
|
77
|
-
Object.
|
|
78
|
-
.map(key => helpers[key])
|
|
77
|
+
Object.values(helpers)
|
|
79
78
|
.forEach((helper) => {
|
|
80
79
|
methodsOfObject(helper, 'Helper')
|
|
81
80
|
.filter(method => method !== 'constructor' && method[0] !== '_')
|