You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CodeceptJS supports three different strategies for distributing tests across workers:
96
96
97
97
#### Default Strategy (`--by test`)
98
+
98
99
Tests are pre-assigned to workers at startup, distributing them evenly across all workers. Each worker gets a predetermined set of tests to run.
99
100
100
101
```sh
101
102
npx codeceptjs run-workers 3 --by test
102
103
```
103
104
104
105
#### Suite Strategy (`--by suite`)
106
+
105
107
Test suites are pre-assigned to workers, with all tests in a suite running on the same worker. This ensures better test isolation but may lead to uneven load distribution.
106
108
107
109
```sh
108
110
npx codeceptjs run-workers 3 --by suite
109
111
```
110
112
111
113
#### Pool Strategy (`--by pool`) - **Recommended for optimal performance**
114
+
112
115
Tests are maintained in a shared pool and distributed dynamically to workers as they become available. This provides the best load balancing and resource utilization.
113
116
114
117
```sh
@@ -121,19 +124,19 @@ The pool mode enables dynamic test distribution for improved worker load balanci
121
124
122
125
### Benefits of Pool Mode
123
126
124
-
***Better load balancing**: Workers never sit idle while others are still running long tests
125
-
***Improved performance**: Especially beneficial when tests have varying execution times
126
-
***Optimal resource utilization**: All CPU cores stay busy until the entire test suite is complete
127
-
***Automatic scaling**: Workers continuously process tests until the pool is empty
127
+
-**Better load balancing**: Workers never sit idle while others are still running long tests
128
+
-**Improved performance**: Especially beneficial when tests have varying execution times
129
+
-**Optimal resource utilization**: All CPU cores stay busy until the entire test suite is complete
130
+
-**Automatic scaling**: Workers continuously process tests until the pool is empty
128
131
129
132
### When to Use Pool Mode
130
133
131
134
Pool mode is particularly effective in these scenarios:
132
135
133
-
***Uneven test execution times**: When some tests take significantly longer than others
134
-
***Large test suites**: With hundreds or thousands of tests where load balancing matters
135
-
***Mixed test types**: When combining unit tests, integration tests, and end-to-end tests
136
-
***CI/CD pipelines**: For consistent and predictable test execution times
136
+
-**Uneven test execution times**: When some tests take significantly longer than others
137
+
-**Large test suites**: With hundreds or thousands of tests where load balancing matters
138
+
-**Mixed test types**: When combining unit tests, integration tests, and end-to-end tests
139
+
-**CI/CD pipelines**: For consistent and predictable test execution times
137
140
138
141
### Usage Examples
139
142
@@ -144,7 +147,7 @@ npx codeceptjs run-workers 4 --by pool
144
147
# Pool mode with grep filtering
145
148
npx codeceptjs run-workers 3 --by pool --grep "@smoke"
Copy file name to clipboardExpand all lines: docs/reports.md
+77-39Lines changed: 77 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ GitHub --
35
35
```
36
36
37
37
output steps use `--steps` option:
38
+
38
39
```
39
40
npx codeceptjs run --steps
40
41
```
@@ -73,12 +74,10 @@ GitHub --
73
74
74
75
To get additional information about test execution use `--debug` option.
75
76
76
-
77
77
```
78
78
npx codeceptjs run --debug
79
79
```
80
80
81
-
82
81
This will show execution steps
83
82
as well as notices from test runner. To get even more information with more technical details like error stack traces,
84
83
and global promises, or events use `--verbose` mode.
@@ -141,7 +140,6 @@ npx codecepjs dry-run --debug
141
140
142
141
> ℹ If you use custom JavaScript code inside tests, or rely on values from `grab*` commands, dry-run may produce error output.
143
142
144
-
145
143
## Testomat.io
146
144
147
145
[Testomat.io](https://testomat.io) is a modern test management tool focused on CodeceptJS and **created by CodeceptJS team**.
@@ -153,18 +151,17 @@ Testomat.io is commercial SaaS service that can receive run reports from local r
153
151
154
152
To receive run reports you should:
155
153
156
-
*[Sign up](https://app.testomat.io/users/sign_up) at Testomat.io
157
-
* Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode)
158
-
* Select "Import from Source Code"
159
-
* Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language.
160
-
* Execute provided command in a terminal with your project. This will be "check-tests" or "check-cucmber" command. It scans all your test files and imports them into Testomat.io. This way all your e2e tests will be visible in one UI.
161
-
* After tests are imported, go to Runs tab and select "Setup automated tests".
162
-
* Follow the instructions:
163
-
154
+
-[Sign up](https://app.testomat.io/users/sign_up) at Testomat.io
155
+
- Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode)
156
+
- Select "Import from Source Code"
157
+
- Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language.
158
+
- Execute provided command in a terminal with your project. This will be "check-tests" or "check-cucmber" command. It scans all your test files and imports them into Testomat.io. This way all your e2e tests will be visible in one UI.
159
+
- After tests are imported, go to Runs tab and select "Setup automated tests".
* You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config:
164
+
- You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config:
168
165
169
166
```js
170
167
plugins: {
@@ -176,14 +173,11 @@ plugins: {
176
173
}
177
174
```
178
175
179
-
* Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io
180
-
* See the run report is created and updated in realtime.
181
-
176
+
- Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io
177
+
- See the run report is created and updated in realtime.
182
178
183
179
[Testomat.io](https://testomat.io) reporter works in the cloud, so it doesn't require you to install additional software. It can be integrated with your CI service to rerun only failed tests, launch new runs from UI, and send report notifications by email or in Slack, MS Teams, or create issue in Jira.
184
180
185
-
186
-
187
181
## ReportPortal
188
182
189
183
For enterprise grade we reporting we recommend using [ReportPortal](https://reportportal.io).
@@ -195,7 +189,6 @@ Think of it as Kibana but for test reports.
195
189
196
190
Use official [CodeceptJS Agent for ReportPortal](https://github.com/reportportal/agent-js-codecept/) to start publishing your test results.
197
191
198
-
199
192
## XML
200
193
201
194
Use default xunit reporter of Mocha to print xml reports. Provide `--reporter xunit` to get the report to screen.
@@ -226,6 +219,21 @@ codeceptjs run --reporter mocha-junit-reporter
226
219
227
220
Result will be located at `output/result.xml` file.
228
221
222
+
Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options.
223
+
224
+
```json
225
+
"mocha": {
226
+
"reporter": "mocha-junit-reporter",
227
+
"reporterOptions": {
228
+
"mochaFile": "output/result.xml"
229
+
}
230
+
},
231
+
```
232
+
233
+
```sh
234
+
codeceptjs run
235
+
```
236
+
229
237
## Html
230
238
231
239
### Built-in HTML Reporter
@@ -252,13 +260,13 @@ exports.config = {
252
260
plugins: {
253
261
htmlReporter: {
254
262
enabled:true,
255
-
output:'./output', // Directory for the report
256
-
reportFileName:'report.html', // Name of the HTML file
257
-
includeArtifacts:true, // Include screenshots/artifacts
258
-
showSteps:true, // Show individual test steps
259
-
showSkipped:true// Show skipped tests
260
-
}
261
-
}
263
+
output:'./output', // Directory for the report
264
+
reportFileName:'report.html', // Name of the HTML file
265
+
includeArtifacts:true, // Include screenshots/artifacts
266
+
showSteps:true, // Show individual test steps
267
+
showSkipped:true,// Show skipped tests
268
+
},
269
+
},
262
270
}
263
271
```
264
272
@@ -299,6 +307,7 @@ npm i mochawesome
299
307
```
300
308
301
309
If you get an error like this
310
+
302
311
```sh
303
312
"mochawesome" reporter not found
304
313
@@ -321,14 +330,29 @@ Configure it to use `output` directory to print HTML reports:
321
330
},
322
331
```
323
332
324
-
Execute CodeceptJS with HTML reporter:
333
+
Execute CodeceptJS with mochawesome reporter:
325
334
326
335
```sh
327
336
codeceptjs run --reporter mochawesome
328
337
```
329
338
330
339
Result will be located at `output/index.html` file.
331
340
341
+
Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options.
342
+
343
+
```json
344
+
"mocha": {
345
+
"reporter": "mochawesome",
346
+
"reporterOptions": {
347
+
"reportDir": "output"
348
+
}
349
+
},
350
+
```
351
+
352
+
```sh
353
+
codeceptjs run
354
+
```
355
+
332
356
### Advanced usage
333
357
334
358
Want to have screenshots for failed tests?
@@ -349,7 +373,7 @@ Then tests with failure will have screenshots.
349
373
This helper should be configured in codecept.conf.ts
350
374
351
375
-`uniqueScreenshotNames` (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suites. This option should be the same as in common helper.
352
-
-`disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper.
376
+
-`disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper.
353
377
354
378
Also if you will add Mochawesome helper, then you will able to add custom context in report:
355
379
@@ -358,21 +382,22 @@ Also if you will add Mochawesome helper, then you will able to add custom contex
-`context`string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context)
400
+
-`context` string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context)
376
401
377
402
## Multi Reports
378
403
@@ -422,6 +447,20 @@ npx codeceptjs run --reporter mocha-multi
422
447
423
448
This will give you cli with steps in console and HTML report in `output` directory.
424
449
450
+
Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options.
451
+
452
+
```json
453
+
"mocha": {
454
+
"reporter": "mocha-multi",
455
+
"reporterOptions": {
456
+
...
457
+
}
458
+
}
459
+
```
460
+
461
+
```sh
462
+
codeceptjs run
463
+
```
425
464
426
465
## Testrail
427
466
@@ -440,7 +479,6 @@ npm i codeceptjs-testrail --save
440
479
Now there is new feature, add the configuration to test run of test plan
441
480

442
481
443
-
444
482
## Tesults
445
483
446
484
Submit test results data from CodeceptJS to [Tesults](https://www.tesults.com) easily with the [codeceptjs-tesults](https://www.npmjs.com/package/codeceptjs-tesults) plugin. Test results data is submitted automatically after a test run completes.
0 commit comments